geom_half_point ¶
geom_half_point(
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,
sampling: Sampling | None = None,
tooltips: Tooltips | None = None,
orientation: str | None = None,
side: Literal | None = None,
transformation: FeatureSpec
| Literal["jitter", "identity"]
| None = None,
range_scale: Number | None = None,
color_by: str | None = None,
fill_by: str | None = None,
na_rm: bool | None = None,
**other_args: Any,
) -> LayerSpec
Points jittered within one half of their x slot.
As geom_half_point in the R package gghalves: each point moves to the
middle of the side half of its slot (a quarter of the slot from x), then
is jittered there. The slot is width (default 0.75) x the x resolution,
dodged by group.
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;
"identity"by default. -
position(str or FeatureSpec, default:None) –Position adjustment;
"dodge"(by the slot 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(). -
sampling(str or FeatureSpec, default:None) –lets_plot sampling; accepted and ignored, as ggrust draws every row.
-
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 half of the slot the points are drawn in.
-
transformation(FeatureSpec or {jitter, identity}, default:None) –How points spread within their half:
position_jitter(width, height, seed)(default), withwidthandheightin data units as in gghalves (defaults:range_scalex a quarter of the slot, and 0.4 x the resolution of the group's y), or"identity"for no jitter. -
range_scale(float, default:0.75) –Default jitter width as a share of the half slot's half width.
-
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 (
size,alpha,color, ...) andwidth.
Returns:
-
LayerSpec–The layer.
Raises:
-
SpecError–If
sideis not"l"or"r", ortransformationis not a jitter or identity. -
UnsupportedValueError–If
range_scaleis 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_point(transformation=position_jitter(width=0.05, seed=1)))