stat_interval ¶
stat_interval(
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,
manual_key: ManualKey | None = None,
tooltips: Tooltips | None = None,
orientation: str | None = None,
point_interval: Literal | None = None,
widths: Sequence[float] | None = None,
na_rm: bool | None = None,
**other_args: Any,
) -> LayerSpec
Stacked quantile intervals of y per x, colored by level.
As stat_interval in the R package ggdist, for sample data: thick
geom_linerange lines (size 5.2, ggdist's 4 in ggrust's units), the
widest drawn first, with
color mapped to "..level.." (discrete, widest first). Add a color
scale (scale_color_brewer, scale_color_viridis) for ggdist's
sequential look.
Parameters:
-
mapping(FeatureSpec, default:None) –Aesthetic mapping from
aes(). Needsy(and usuallyx). -
data(DataFrame or dict, default:None) –Layer data; inherits the plot data when None.
-
geom(str, default:"linerange") –Geom that draws the intervals.
-
position(str or FeatureSpec, default:None) –Position adjustment; none 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. -
point_interval((median_qi, mean_qi, mode_qi), default:"median_qi") –The point summary the intervals belong to.
-
widths(list of float, default:[0.5, 0.8, 0.95]) –Interval levels (ggdist's
.width), each in (0, 1]. -
na_rm(bool, default:None) –True removes rows with missing values silently.
-
**other_args(Any) –Constant aesthetics (
size,alpha; a constantcolorreplaces the level coloring).
Returns:
-
LayerSpec–The layer.
Raises:
-
SpecError–If
point_intervalis not an accepted name or a width is outside (0, 1]. -
UnsupportedValueError–If
widthsis not a list of numbers.
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")) + stat_interval()
... + scale_color_brewer(palette="Blues"))