| geom_bagplot | R Documentation |
Render bagplots from tagged data comprising medians, hulls, contours, and outlier specifications.
geom_bagplot(
mapping = NULL,
data = NULL,
stat = "bagplot",
position = "identity",
outlier_points = !outlier_labels,
outlier_labels = FALSE,
...,
bag.linewidth = sync(),
bag.linetype = sync(),
bag.colour = "black",
bag.color = NULL,
bag.fill = sync(),
bag.alpha = NA,
median.shape = 21L,
median.stroke = sync(),
median.size = 5,
median.colour = sync(),
median.color = NULL,
median.fill = "white",
median.alpha = NA,
fence.linewidth = 0.25,
fence.linetype = 0L,
fence.colour = sync(),
fence.color = NULL,
fence.fill = sync(),
fence.alpha = 0.25,
outlier.shape = sync(),
outlier.stroke = sync(),
outlier.size = sync(),
outlier.colour = sync(),
outlier.color = NULL,
outlier.fill = NA,
outlier.alpha = NA,
text.size = 3.88,
text.colour = sync(),
text.color = sync(),
text.alpha = sync(),
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
outlier_points |
Logical; whether to plot outlier markers. Defaults to
|
outlier_labels |
Logical; whether to plot outlier labels. Defaults to
|
... |
Additional arguments passed to |
bag.linetype, bag.linewidth, bag.colour, bag.color, bag.fill, bag.alpha |
Default aesthetics for bags. Set to |
median.shape, median.stroke, median.size, median.colour, median.color, median.fill, median.alpha |
Default aesthetics for medians. Set to |
fence.linetype, fence.linewidth, fence.colour, fence.color, fence.fill, fence.alpha |
Default aesthetics for fences. Set to |
outlier.shape, outlier.stroke, outlier.size, outlier.colour, outlier.color, outlier.fill, outlier.alpha |
Default aesthetics for outliers. Set to |
text.size, text.colour, text.color, text.alpha |
Default aesthetics for outlier labels. Set to NULL to inherit from the data's aesthetics. |
na.rm |
Passed to |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom_bagplot() is designed to pair with stat_bagplot(),
analogously to the pairing of ggplot2::geom_boxplot() with
ggplot2::stat_boxplot().
Because the optional components are more expensive to compute in this
setting, they are controlled by parameters passed to the stat. Auxiliary
aesthetics like median.colour are available that override auxiliary
defaults, and these in turn override the standard defaults. Auxiliary
defaults also take effect when auxiliary aesthetics are passed NULL, so
that stat_bagplot() and geom_bagplot() have the same default behavior.
Pass sync() (instead of NULL, as in ggplot2::geom_boxplot()) to
synchronize an auxiliary aesthetic with its standard counterpart.
WARNING:
The trade-off between precision and runtime is greater for depth estimation
than for density estimation. At the resolution of the default 100
\times 100 grid, basic examples may vary noticeably when starting from
different random seeds.
A ggproto layer.
geom_bagplot() understands the following aesthetics (required aesthetics
are in bold):
x
y
component
linewidth
linetype
colour
fill
alpha
shape
stroke
size
label
hjust
vjust
angle
group
Other geom layers:
geom_axis(),
geom_isoline(),
geom_lineranges(),
geom_rule(),
geom_text_radiate(),
geom_vector()
# Motor Trends base plot with factorized cylinder counts
p <- mtcars %>%
transform(name = rownames(mtcars)) %>%
transform(cyl = factor(cyl)) %>%
ggplot(aes(x = wt, y = disp, label = name)) +
theme_bw()
# basic bagplot
p + geom_bagplot()
# group by cylinder count
p + geom_bagplot(
fraction = 0.4, coef = 1.2,
aes(fill = cyl, linetype = cyl, color = cyl)
)
# using normally unmapped aesthetics
p + geom_bagplot(
fraction = 0.4, coef = 1.2,
aes(fill = cyl, linetype = cyl, color = cyl),
median.color = "black",
fence.linetype = sync(), fence.colour = "black",
outlier.shape = "asterisk", outlier.colour = "black"
)
# label outliers
p + geom_bagplot(
fraction = 0.4, coef = 1.2,
outlier_labels = TRUE,
aes(fill = cyl, linetype = cyl, color = cyl)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.