Skip to content

stat_boxplot

stat_boxplot(
    mapping: FeatureSpec | None = None,
    *,
    data: PlotData | None = None,
    geom: str | None = None,
    position: Position | None = None,
    show_legend: bool | None = None,
    inherit_aes: bool | None = None,
    tooltips: Tooltips | None = None,
    orientation: str | None = None,
    coef: Number | None = None,
    color_by: str | None = None,
    fill_by: str | None = None,
    na_rm: bool | None = None,
    **other_args: Any,
) -> FeatureSpec

Quartiles, whiskers and outliers of y per x (stat="boxplot"), drawn as boxplots.

Outliers are drawn by a second point layer, as geom_boxplot.

stat_boxplot(...) is geom_boxplot(stat="boxplot", ...); another geom draws the same computed rows with that geom.

Parameters:

  • mapping (FeatureSpec, default: None ) –

    Aesthetic mapping from aes().

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

    Layer data; inherits the plot data when None.

  • geom (str, default: None ) –

    Geom that draws the computed rows, by name; "boxplot" when None.

  • 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.

  • 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 ) –

    "y" draws along the y axis; a discrete y with a continuous x picks it by default.

  • coef (float, default: 1.5 ) –

    Whisker length as a multiple of the interquartile range; rows beyond the whiskers are outliers.

  • 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) –

    Options of the geom and constant aesthetics such as color="red".

Returns:

  • FeatureSpec –

    The layer; the default boxplot geom adds the outlier layer.

Examples:

>>> from ggrust import *
>>> data = {"day": ["Mon"] * 5 + ["Tue"] * 5,
...         "minutes": [12, 15, 14, 30, 13, 20, 22, 19, 21, 18]}
>>> plot = ggplot(data, aes("day", "minutes")) + stat_boxplot(coef=1.0)