Description Usage Arguments Value Note Author(s) See Also Examples
Takes a set of plots and combines them into one ‘multiplot’, allowing the user to specify how the graphs are laid out across the rows and columns of the plot. Specifically designed to overcome problems with more standard approaches to creating multiplots using ggplot2
graphs.
1 |
... |
A series of comma-separated plots. E.g. |
plotlist |
A |
cols |
Numeric. The number of columns that the multiplot should use when arranging the plots. The default is |
layout |
A |
Returns one plot.
Closely based upon http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/
Paul Williamson
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ## Create some ggplot graphs
load.package("ggplot2")
plot1 <- ggplot(data=survey) + geom_bar(aes(x=Health))
plot2 <- ggplot(data=survey) + geom_bar(aes(x=Tenure))
plot3 <- ggplot(data=survey) + geom_bar(aes(x=Age))
## Combine multiple ggplots in one plot
multiplot(plot1, plot2, plot3)
## Change number of columns used to create plot
multiplot(plot1, plot2, plot3, cols=2)
## Pass the plots as a list of plots
plots <- list(plot1, plot2, plot3)
multiplot(plotlist=plots, cols=3)
## Specify which cells in plot grid each plot occupies
multiplot(plotlist=plots, layout=matrix(c(1,2,3,3), nrow=2, byrow=TRUE))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.