Description Usage Arguments Value Examples
multiplot() Multiple plot function
1 |
... |
other parameters passed from ggplot |
plotlist |
a list of ggplots |
cols |
number of columns in the output grid |
layout |
a matrix describing layout of the output |
a page layout of ggplots
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | library(ggplot2)
p1 <- ggplot(ChickWeight, aes(x=Time, y=weight, colour=Diet, group=Chick)) +
geom_line() +
ggtitle("Growth curve for individual chicks")
p2 <- ggplot(ChickWeight, aes(x=Time, y=weight, colour=Diet)) +
geom_point(alpha=.3) +
geom_smooth(alpha=.2, size=1) +
ggtitle("Fitted growth curve per diet")
p3 <- ggplot(subset(ChickWeight, Time==21), aes(x=weight, colour=Diet)) +
geom_density() +
ggtitle("Final weight, by diet")
p4 <- ggplot(subset(ChickWeight, Time==21), aes(x=weight, fill=Diet)) +
geom_histogram(colour="black", binwidth=50) +
facet_grid(Diet ~ .) +
ggtitle("Final weight, by diet") +
theme(legend.position="none")
multiplot(p1,p2,p3,p4,cols=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.