geom_beeswarm {ggbeeswarm} | R Documentation |
Points, jittered to reduce overplotting using the beeswarm package
Description
The beeswarm geom is a convenient means to offset points within categories to reduce overplotting. Uses the beeswarm package
Usage
geom_beeswarm(
mapping = NULL,
data = NULL,
stat = "identity",
...,
method = "swarm",
cex = 1,
side = 0L,
priority = "ascending",
fast = TRUE,
dodge.width = NULL,
corral = "none",
corral.width = 0.9,
groupOnX = NULL,
beeswarmArgs = list(),
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, either as a |
... |
Other arguments passed on to |
method |
Method for arranging points (see Details below) |
cex |
Scaling for adjusting point spacing (see |
side |
Direction to perform jittering: 0: both directions; 1: to the right or upwards; -1: to the left or downwards. |
priority |
Method used to perform point layout (see Details below) |
fast |
Use compiled version of swarm algorithm? This option is ignored
for all methods expect |
dodge.width |
Amount by which points from different aesthetic groups will be dodged. This requires that one of the aesthetics is a factor. |
corral |
|
corral.width |
|
groupOnX |
|
beeswarmArgs |
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
Aesthetics
@section Aesthetics:
geom_point()
understands the following aesthetics (required aesthetics are in bold):
x
y
alpha
colour
fill
group
shape
size
stroke
Learn more about setting these aesthetics in vignette("ggplot2-specs")
.
See Also
geom_quasirandom()
an alternative method,
beeswarm::swarmx()
how spacing is determined,
ggplot2::geom_point()
for regular, unjittered points,
ggplot2::geom_jitter()
for jittered points,
ggplot2::geom_boxplot()
for another way of looking at the conditional
distribution of a variable
Examples
ggplot2::qplot(class, hwy, data = ggplot2::mpg, geom='beeswarm')
# Generate fake data
distro <- data.frame(
'variable'=rep(c('runif','rnorm'),each=100),
'value'=c(runif(100, min=-3, max=3), rnorm(100))
)
ggplot2::qplot(variable, value, data = distro, geom='beeswarm')
ggplot2::ggplot(distro,aes(variable, value)) +
geom_beeswarm(priority='density',size=2.5)