stat_halfeye ¶
stat_halfeye(
mapping: FeatureSpec | None = None,
*,
data: PlotData | 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,
density: Literal | None = None,
bandwidth: Literal["dpi", "nrd0", "nrd"]
| Number
| None = None,
adjust: Number | None = None,
trim: bool | None = None,
n: int | None = None,
normalize: Literal | None = None,
scale: Number | None = None,
side: Literal | None = None,
point_interval: Literal | None = None,
widths: Sequence[float] | None = None,
interval_size_range: tuple[float, float] | None = None,
fatten_point: Number | None = None,
na_rm: bool | None = None,
**other_args: Any,
) -> FeatureSpec
Half-eye plot: a density slab with a point interval at its base, per x.
As stat_halfeye in the R package ggdist: a stat_slab layer and a
stat_pointinterval layer over the same data and position. Constant
fill and alpha go to the slab; other constants (color,
size, linewidth, shape) go to the interval.
Parameters:
-
mapping(FeatureSpec, default:None) –Aesthetic mapping from
aes(), shared by both layers. -
data(DataFrame or dict, default:None) –Layer data; inherits the plot data when None.
-
position(str or FeatureSpec, default:None) –Position adjustment of both layers, e.g.
position_dodge(width=0.9). -
show_legend(bool, default:None) –False hides both layers from the legend.
-
inherit_aes(bool, default:None) –False ignores the plot's default mapping for these layers.
-
manual_key(str or FeatureSpec, default:None) –The slab's key in a manual legend: a label, or
layer_key(). -
tooltips(FeatureSpec or list of str, default:None) –Tooltip content of both layers.
-
orientation(str, default:None) –"y"draws along the y axis; a discrete y with a continuous x picks it. -
density(optional, default:None) –The slab's options; see
stat_slab. -
bandwidth(optional, default:None) –The slab's options; see
stat_slab. -
adjust(optional, default:None) –The slab's options; see
stat_slab. -
trim(optional, default:None) –The slab's options; see
stat_slab. -
n(optional, default:None) –The slab's options; see
stat_slab. -
normalize(optional, default:None) –The slab's options; see
stat_slab. -
scale(optional, default:None) –The slab's options; see
stat_slab. -
side(optional, default:None) –The slab's options; see
stat_slab. -
point_interval(optional, default:None) –The interval's options; see
stat_pointinterval. -
widths(optional, default:None) –The interval's options; see
stat_pointinterval. -
interval_size_range(optional, default:None) –The interval's options; see
stat_pointinterval. -
fatten_point(optional, default:None) –The interval's options; see
stat_pointinterval. -
na_rm(bool, default:None) –True removes rows with missing values silently.
-
**other_args(Any) –Constant aesthetics, split between the layers as above, and
width.
Returns:
-
FeatureSpecArray–The slab layer, then the point interval layer.
Raises:
-
SpecError–If an option of either layer is invalid (see
stat_slabandstat_pointinterval). -
UnsupportedValueError–If an option has the wrong type.
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_halfeye()