geom_jitter {ggplot2} | R Documentation |
The jitter geom is a convenient default for geom_point
with position = 'jitter'. See
position_jitter
to see how to adjust amount
of jittering.
geom_jitter(mapping = NULL, data = NULL, stat = "identity", position = "jitter", na.rm = FALSE, ...)
mapping |
The aesthetic mapping, usually constructed
with |
data |
A layer specific dataset - only needed if you want to override the plot defaults. |
stat |
The statistical transformation to use on the data for this layer. |
position |
The position adjustment to use for overlappling points on this layer |
na.rm |
If |
... |
other arguments passed on to
|
geom_jitter
understands the following aesthetics (required aesthetics are in bold):
x
y
alpha
colour
fill
shape
size
geom_point
for regular, unjittered points,
geom_boxplot
for another way of looking at
the conditional distribution of a variable,
position_jitter
for examples of using
jittering with other geoms
p <- ggplot(mpg, aes(displ, hwy)) p + geom_point() p + geom_point(position = "jitter") # Add aesthetic mappings p + geom_jitter(aes(colour = cyl)) # Vary parameters p + geom_jitter(position = position_jitter(width = .5)) p + geom_jitter(position = position_jitter(height = .5)) # Use qplot instead qplot(displ, hwy, data = mpg, geom = "jitter") qplot(class, hwy, data = mpg, geom = "jitter") qplot(class, hwy, data = mpg, geom = c("boxplot", "jitter")) qplot(class, hwy, data = mpg, geom = c("jitter", "boxplot"))