lets_plot.geom_boxplot(mapping=None, *, data=None, stat=None, position=None, show_legend=None, sampling=None, tooltips=None, orientation=None, fatten=None, outlier_color=None, outlier_fill=None, outlier_shape=None, outlier_size=None, varwidth=None, whisker_width=None, **other_args)

Display the distribution of data based on a five number summary (“minimum”, first quartile (Q1), median, third quartile (Q3), and “maximum”), and “outlying” points individually.


Set of aesthetic mappings created by aes() function. Aesthetic mappings describe the way that variables in the data are mapped to plot “aesthetics”.

datadict or DataFrame or polars.DataFrame

The data to be displayed in this layer. If None, the default, the data is inherited from the plot data as specified in the call to ggplot.

statstr, default=’boxplot’

The statistical transformation to use on the data for this layer, as a string.

positionstr or FeatureSpec

Position adjustment, either as a string (‘identity’, ‘stack’, ‘dodge’, …), or the result of a call to a position adjustment function.

show_legendbool, default=True

False - do not show legend for this layer.


Result of the call to the sampling_xxx() function. Value None (or ‘none’) will disable sampling for this layer.


Result of the call to the layer_tooltips() function. Specifies appearance, style and content.

orientationstr, default=’x’

Specifies the axis that the layer’ stat and geom should run along. Possible values: ‘x’, ‘y’.

fattenfloat, default=1.0

A multiplicative factor applied to size of the middle bar.


Default color aesthetic for outliers.


Default fill aesthetic for outliers.


Default shape aesthetic for outliers.


Default size aesthetic for outliers.

varwidthbool, default=False

If False make a standard box plot. If True, boxes are drawn with widths proportional to the square-roots of the number of observations in the groups.

whisker_widthfloat, default=0.0

A multiplicative factor applied to the box width to draw horizontal segments on whiskers.


Other arguments passed on to the layer. These are often aesthetics settings used to set an aesthetic to a fixed value, like color=’red’, fill=’blue’, size=3 or shape=21. They may also be parameters to the paired geom/stat.


Geom object specification.


Computed variables:

  • ..lower.. : lower hinge, 25% quantile.

  • ..middle.. : median, 50% quantile.

  • ..upper.. : upper hinge, 75% quantile.

  • ..ymin.. : lower whisker = smallest observation greater than or equal to lower hinge - 1.5 * IQR.

  • ..ymax.. : upper whisker = largest observation less than or equal to upper hinge + 1.5 * IQR.

geom_boxplot() understands the following aesthetics mappings:

  • lower : lower hinge.

  • middle : median.

  • upper : upper hinge.

  • ymin : lower whisker.

  • ymax : upper whisker.

  • alpha : transparency level of a layer. Understands numbers between 0 and 1.

  • color (colour) : color of a geometry lines. Can be continuous or discrete. For continuous value this will be a color gradient between two colors.

  • fill : color of geometry filling.

  • size : lines width.

  • linetype : type of the line of border. Codes and names: 0 = ‘blank’, 1 = ‘solid’, 2 = ‘dashed’, 3 = ‘dotted’, 4 = ‘dotdash’, 5 = ‘longdash’, 6 = ‘twodash’.

  • width : width of boxplot. Typically ranges between 0 and 1. Values that are greater than 1 lead to overlapping of the boxes.


1import numpy as np
2from lets_plot import *
4n = 100
6x = np.random.choice(['a', 'b', 'c'], size=n)
7y = np.random.normal(size=n)
8ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + \
9    geom_boxplot()