geom_half_boxplot ¶
geom_half_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,
side: Literal | None = None,
nudge: Number | None = None,
errorbar_draw: bool | None = None,
errorbar_length: Number | 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,
color_by: str | None = None,
fill_by: str | None = None,
na_rm: bool | None = None,
**other_args: Any,
) -> LayerSpec | FeatureSpec
Half of a box-and-whisker plot, on one side of each x.
As geom_half_boxplot in the R package gghalves: the box runs from its
outer edge to x (less nudge), the whiskers stand at x (moved nudge
towards the box), with fences reaching outwards. With the default stat, a
second point layer (stat="boxplot_outlier") draws the outliers beside
the whiskers, as geom_boxplot does.
Parameters:
-
mapping(FeatureSpec, default:None) –Aesthetic mapping from
aes(). Needsxandy. -
data(DataFrame or dict, default:None) –Layer data; inherits the plot data when None.
-
stat(str, default:None) –Statistical transformation, by name;
"boxplot"by default. -
position(str or FeatureSpec, default:None) –Position adjustment;
"dodge"(by the box width) by default. -
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) –This layer's key in a manual legend: a label, or
layer_key(). -
tooltips(FeatureSpec or list of str, default:None) –Tooltip content:
layer_tooltips(), a list of column names, or"none". -
orientation(str, default:None) –"y"draws along the y axis; a discrete y with a continuous x picks it. -
side((l, r), default:"l") –The side of x the half box is drawn on.
-
nudge(float, default:0) –Distance (data units) between x and the box's inner edge, and the whiskers' shift towards the box.
-
errorbar_draw(bool, default:True) –Draw fences at the whisker ends.
-
errorbar_length(float, default:0.5) –Fence length as a share of the half box, from 0 to 1.
-
fatten(float, default:2) –Multiplier of the median line width.
-
outlier_alpha(optional, default:None) –Style of the outlier points (also
outlier_shape,outlier_size,outlier_stroke);color,fill,shape,sizeandstrokeinother_argsare the fallback. -
outlier_color(optional, default:None) –Style of the outlier points (also
outlier_shape,outlier_size,outlier_stroke);color,fill,shape,sizeandstrokeinother_argsare the fallback. -
outlier_fill(optional, default:None) –Style of the outlier points (also
outlier_shape,outlier_size,outlier_stroke);color,fill,shape,sizeandstrokeinother_argsare the fallback. -
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.
-
color_by(str, default:None) –Aesthetic the
colorscale applies to ("color"or"fill"). -
fill_by(str, default:None) –Aesthetic the
fillscale applies to ("fill"or"color"). -
na_rm(bool, default:None) –True removes rows with missing values silently.
-
**other_args(Any) –Constant aesthetics,
width(default 0.75) andcoef.
Returns:
-
LayerSpec or FeatureSpecArray–The box layer, plus the outlier layer with the default stat.
Raises:
-
SpecError–If
sideis not"l"or"r", orerrorbar_lengthis outside [0, 1]. -
UnsupportedValueError–If
nudgeorerrorbar_lengthis not a number.
Examples:
>>> from ggrust import *
>>> data = {"diet": ["veg"] * 6 + ["meat"] * 6,
... "weight": [61, 58, 66, 70, 63, 59, 72, 80, 77, 69, 85, 74]}
>>> plot = (ggplot(data, aes("diet", "weight"))
... + geom_half_boxplot(side="r") + geom_half_point(side="l"))