Skip to content

geom_boxplot

geom_boxplot(
    mapping: FeatureSpec | None = None,
    *,
    data: PlotData | None = None,
    stat: str | None = None,
    position: Position | None = None,
    show_legend: bool | None = None,
    inherit_aes: bool | None = None,
    manual_key: ManualKey | None = None,
    tooltips: Tooltips | None = None,
    orientation: str | None = None,
    fatten: Number | None = None,
    outlier_alpha: Number | None = None,
    outlier_color: Color | None = None,
    outlier_fill: Color | None = None,
    outlier_shape: Shape | None = None,
    outlier_size: Number | None = None,
    outlier_stroke: Number | None = None,
    varwidth: bool | None = None,
    whisker_width: Number | None = None,
    width_unit: str | None = None,
    color_by: str | None = None,
    fill_by: str | None = None,
    na_rm: bool | None = None,
    **other_args: Any,
) -> FeatureSpec

Box and whiskers plot, dodged by group.

With the default stat, a second point layer (stat="boxplot_outlier") draws the outliers, as in lets_plot. Unlike lets_plot, coef also reaches the outlier layer, so points beyond shortened whiskers are not lost.

Parameters:

  • mapping (FeatureSpec, default: None ) –

    Aesthetic mapping from aes().

  • data (DataFrame or dict, default: None ) –

    Layer data; inherits the plot data when None.

  • outlier_alpha (optional, default: None ) –

    Style of the outlier points (also outlier_shape, outlier_size, outlier_stroke); color, fill, shape, size and stroke in other_args are the fallback.

  • outlier_color (optional, default: None ) –

    Style of the outlier points (also outlier_shape, outlier_size, outlier_stroke); color, fill, shape, size and stroke in other_args are the fallback.

  • outlier_fill (optional, default: None ) –

    Style of the outlier points (also outlier_shape, outlier_size, outlier_stroke); color, fill, shape, size and stroke in other_args are the fallback.

  • stat (str, default: None ) –

    Statistical transformation, by name.

  • position (str or FeatureSpec, default: None ) –

    Position adjustment: a name such as "dodge" or a position_*() spec.

  • show_legend (bool, default: None ) –

    False hides this layer from the legend.

  • inherit_aes (bool, default: None ) –

    False ignores the plot's default mapping for this layer.

  • manual_key (str or FeatureSpec, default: None ) –

    A legend key for this layer, as in lets_plot; not supported yet (ggrust warns).

  • tooltips (FeatureSpec or list of str, default: None ) –

    Tooltip content: layer_tooltips(), a list of column names, or "none" to disable tooltips (HTML output).

  • orientation (str, default: None ) –

    Set to "y" to draw the geom along the y axis.

  • fatten (float, default: None ) –

    Multiplier of the median line width.

  • outlier_shape (int or str, default: None ) –

    Shape of the outlier points.

  • outlier_size (float, default: None ) –

    Size of the outlier points.

  • outlier_stroke (float, default: None ) –

    Stroke width of the outlier points.

  • varwidth (bool, default: None ) –

    True makes box widths proportional to the square root of the group size.

  • whisker_width (float, default: None ) –

    Width of the whisker ends, relative to the box width.

  • width_unit (str, default: None ) –

    Unit of width: "res", "identity", "size" or "px".

  • color_by (str, default: None ) –

    Aesthetic the color scale applies to ("color" or "fill").

  • fill_by (str, default: None ) –

    Aesthetic the fill scale applies to ("fill" or "color").

  • na_rm (bool, default: None ) –

    True removes rows with missing values silently; otherwise they are removed with a warning.

  • **other_args (Any) –

    Constant aesthetics and the geom's options, as in lets_plot.

Returns:

  • LayerSpec or FeatureSpecArray –

    The box layer, plus the outlier layer with the default stat.