multiplot | R Documentation |
mulitplot
prints several ggplot plot-objects on one device
multiplot(..., plotlist = NULL, cols = 1, layout = NULL, titles = NULL, widths = NULL, heights = NULL)
... |
Several |
plotlist |
Optional - a list of |
cols |
Number of columns of the layout in which the objects are to be plotted. Will be ignored if layout is present. |
layout |
A matrix specifying the layout. If present, 'cols' is ignored. |
titles |
A vector with titles for the individual plots |
If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE), then plot 1 will go in the upper left, 2 will go in the upper right, and 3 will go all the way across the bottom.
Original code was taken from R Graphics Cookbook courtesy of Winston Change http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/
Florian Klinglmueller float@lefant.net, Winston Chang
Chang, W. (2012). R graphics cookbook. O'Reilly Media, Inc.
x <- rnorm(100) y <- rnorm(100) d <- data.frame('y'=y,'x'=x,'s'=x+y) p1 <- qplot(y,x,data=d,) p2 <- qplot(y,s,data=d) multiplot(p1,p2,cols=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.