geom_bagplot {gggda} | R Documentation |
Bagplots
Description
Render bagplots from tagged data comprising medians, hulls, contours, and outlier specifications.
Usage
geom_bagplot(
mapping = NULL,
data = NULL,
stat = "bagplot",
position = "identity",
...,
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,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
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
|
... |
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 |
na.rm |
Passed to |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
Details
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.
Value
Aesthetics
geom_bagplot()
understands the following aesthetics (required aesthetics
are in bold):
-
x
-
y
-
component
-
linewidth
-
linetype
-
colour
-
fill
-
alpha
-
shape
-
stroke
-
size
-
group
See Also
Other geom layers:
geom_axis()
,
geom_isoline()
,
geom_lineranges()
,
geom_rule()
,
geom_text_radiate()
,
geom_vector()
Examples
# Motor Trends base plot with factorized cylinder counts
p <- mtcars %>%
transform(cyl = factor(cyl)) %>%
ggplot(aes(x = wt, y = disp)) +
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"
)