stat_summary_xy ¶
stat_summary_xy(
mapping: FeatureSpec | None = None,
*,
data: PlotData | None = None,
geom: str | None = None,
position: Position | None = None,
show_legend: bool | None = False,
inherit_aes: bool | None = None,
tooltips: Tooltips | None = None,
fun_x: Literal | None = None,
fun_y: Literal | None = None,
na_rm: bool | None = None,
**other_args: Any,
) -> LayerSpec
One row per group at a summary of x and of y (stat="summary_xy"), as ggpp.
As stat_centroid(), with a summary per axis: fun_x of x and fun_y of
y, over the rows where both are finite.
Parameters:
-
mapping(FeatureSpec, default:None) –Aesthetic mapping from
aes():x,y(required), and the geom's own, such aslabelorcolor. -
data(DataFrame or dict, default:None) –Layer data; inherits the plot data when None.
-
geom(str, default:"point") –Geom that draws the summaries, e.g.
"text"or"label". -
position(str or FeatureSpec, default:None) –Position adjustment: a name such as
"identity"or aposition_*()spec. -
show_legend(bool, default:False) –True adds this layer to the legend (ggpp leaves it out).
-
inherit_aes(bool, default:None) –False ignores the plot's default mapping for this layer.
-
tooltips(FeatureSpec or list of str, default:None) –Tooltip content:
layer_tooltips(), a list of column names, or"none"to disable tooltips (HTML output). -
fun_x((mean, median), default:"mean") –Summary of x.
-
fun_y((mean, median), default:"mean") –Summary of y.
-
na_rm(bool, default:None) –True removes rows with missing values silently; otherwise they are removed with a warning.
-
**other_args(Any) –Constant aesthetics such as
size=6, and the geom's options.
Returns:
-
LayerSpec–The layer.
Examples:
>>> from ggrust import *
>>> data = {"day": [1, 2, 3, 1, 2, 3], "visits": [5, 9, 40, 2, 3, 4], "shop": list("aaabbb")}
>>> plot = (
... ggplot(data, aes("day", "visits", color="shop"))
... + geom_point()
... + stat_summary_xy(fun_x="mean", fun_y="median", shape=4, size=6)
... )