geom_half_violin ¶
geom_half_violin(
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,
nudge: Number | None = None,
draw_quantiles: Sequence[float] | None = None,
trim: bool | None = None,
scale: str | None = None,
bw: str | Number | None = None,
adjust: Number | None = None,
kernel: str | None = None,
n: int | None = None,
color_by: str | None = None,
fill_by: str | None = None,
na_rm: bool | None = None,
**other_args: Any,
) -> LayerSpec
Half of a violin: the density of y on one side of each x.
As geom_half_violin in the R package gghalves. The density is
stat="ydensity" (as geom_violin); the shape is one half of the
violin, width (default 0.75) x the x resolution wide in all, 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;
"ydensity"by default. -
position(str or FeatureSpec, default:None) –Position adjustment;
"dodge"(by the span 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 ("l"is then below); a discrete y with a continuous x picks it by default. -
side((l, r), default:"l") –The side of x the half violin is drawn on.
-
nudge(float, default:0) –Distance (data units) between x and the flat side of the half violin.
-
draw_quantiles(list of float, default:None) –Quantiles (each in [0, 1]) to draw lines across the half violin at.
-
trim(bool, default:True) –False extends the density 3 bandwidths beyond the data.
-
scale((area, count, width), default:"area") –How the violins of the layer compare in width.
-
bw(str or float, default:None) –Bandwidth:
"nrd0"(default),"nrd"or a number. -
adjust(float, default:None) –Multiplies the bandwidth.
-
kernel(str, default:None) –Kernel,
"gaussian"by default. -
n(int, default:None) –Number of points the density is evaluated at (512).
-
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 (
fill,color,alpha,size, ...) andwidth.
Returns:
-
LayerSpec–The layer.
Raises:
-
SpecError–If
sideis not"l"or"r", or a quantile is outside [0, 1]. -
UnsupportedValueError–If
nudgeis 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", fill="diet"))
... + geom_half_violin() + geom_half_point())