| geom_boxplot {ggplot2} | R Documentation |
Box and whiskers plot
geom_boxplot(mapping=NULL, data=NULL, stat="boxplot", position="dodge", outlier.colour="black", outlier.shape=19, outlier.size=1, ...)
mapping |
mapping between variables and aesthetics generated by aes |
data |
dataset used in this layer, if not specified uses plot dataset |
stat |
statistic used by this layer |
position |
position adjustment used by this layer |
outlier.colour |
colour for outlying points |
outlier.shape |
shape of outlying points |
outlier.size |
size of outlying points |
... |
other arguments |
This page describes geom_boxplot, see layer and qplot for how to create a complete plot from individual components.
A layer
The following aesthetics can be used with geom_boxplot. Aesthetics are mapped to variables in the data with the aes function: geom\_boxplot(\code{aes}(x = var))
x: x position (required)
min: minimum of interval (required)
max: maximum of interval (required)
weight: observation weight used in statistical transformation
colour: border colour
fill: internal colour
size: size
Hadley Wickham, http://had.co.nz/
stat_quantile: View quantiles conditioned on a continuous variable
geom_jitter: Another way to look at conditional distributions
## Not run:
p <- ggplot(mtcars, aes(y=mpg, x=factor(cyl)))
p + geom_boxplot()
p + stat_boxplot()
p + geom_boxplot() + geom_jitter()
p + geom_boxplot() + coord_flip()
p + geom_boxplot(outlier.colour = "green", outlier.size = 3)
# Add aesthetic mappings
p + geom_boxplot(aes(fill=cyl))
p + geom_boxplot(aes(fill=factor(cyl)))
p + geom_boxplot(aes(colour=cyl), size=1)
# Dodged boxplots
# - automatically split when an aesthetic variable is a factor
p + geom_boxplot(aes(colour=factor(am)))
p + geom_boxplot(aes(fill=factor(vs)), colour="black")
p + geom_boxplot(aes(size=factor(gear)))
# Set aesthetics to fixed value
p + geom_boxplot(fill="black", colour="white", size=1)
# Scales vs. Coordinate transforms
m <- ggplot(movies, aes(y=votes, x=rating, group=round_any(rating,0.5)))
m + geom_point()
m + geom_boxplot()
m + geom_boxplot() + scale_y_log10()
m + geom_boxplot() + coord_trans(y="log10")
m + geom_boxplot() + scale_y_log10() + coord_trans(y="log10")
# Boxplots with continuous x
qplot(year, budget, data=movies, geom="boxplot")
qplot(year, budget, data=movies, geom="boxplot", group=year)
qplot(year, budget, data=movies, geom="boxplot", group=round_any(year, 10, floor))
# Use qplot instead
qplot(factor(cyl), mpg, data=mtcars, geom="boxplot")
qplot(factor(cyl), mpg, data=mtcars, geom="boxplot") + coord_flip()
## End(Not run)