StatDistMean receives the rows that ggplot2 has assigned to each panel and
emits their mean as an xintercept. Because ggplot2 transforms position
scales and applies hard-limit out-of-bounds handling before a stat runs, the
result follows that lifecycle: a transformed scale changes the values being
averaged, hard scale limits can remove values, and coordinate zoom does not
change the result.
Usage
StatDistMean
stat_dist_mean(
mapping = NULL,
data = NULL,
geom = "vline",
position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)Format
StatDistMean is a ggplot2::Stat object.
Arguments
- mapping
Set of aesthetic mappings created by
ggplot2::aes().- data
The data to be displayed in this layer.
- geom
The geometric object used to display the data. Defaults to
"vline".- position
A position adjustment. Defaults to
"identity".- ...
Other arguments passed to
ggplot2::layer().- na.rm
If
FALSE, the default, missing values are removed with a warning. IfTRUE, missing values are silently removed.- show.legend
Logical. Should this layer be included in the legends?
- inherit.aes
If
FALSE, override the default aesthetics rather than combining with them.
Details
stat_dist_mean() is the conventional layer constructor. It computes from
x and defaults to a vertical line; show_mean() is the teaching-oriented
helper that resolves a distribution plot's mapping and styles this layer.
Since the stat computes once per panel, styling aesthetics from the source
data cannot be mapped; set them to one value, or facet the plot to compute
one mean per group.
See also
show_mean() and gf_model().