multiplot | R Documentation |
Multiple plot function, accepts a list of lattice plot (not ggplot) objects
multiplot(
...,
plotlist = NULL,
cols = NULL,
layout = NULL,
title = "",
title.size = 20
)
plotlist |
objects can be passed in ..., or to plotlist (as a list of plot objects) (p1,p2,p3), (plotlist=list(p1,p2,p3)), or (p1,plotlist=list(p2,p3)) |
title |
string, NULL or ” both fine |
cols: |
Number of columns in layout. If present, 'cols' is ignored. If both cols and layout NULL, auto calculate |
layout: |
A matrix specifying the layout.
|
returns nothing (NULL)
inspired by Cookbook R
# examples for ggmultiplot, as reference here
plots <- list() # new empty list
for (i in 1:6) {
p1 = qplot(1:10, rnorm(10), main = i)
plots[[i]] <- p1 # add each plot into plot list
}
ggmultiplot(plotlist = plots, cols = 3)
ggmultiplot(p1,p2,p3, cols = 3)
plots <- list()
for (i in 1:5) {
p1 = qplot(1:10, rnorm(10), main = i)
plots[[i]] <- p1
}
layout <- matrix(c(1, 1, 2, 3, 4, 5), nrow = 2, byrow = TRUE)
ggmultiplot(plotlist = plots, layout = layout)
layout <- matrix(c(1, NA, 2,
3, 4, 5), nrow = 2, byrow = TRUE) # NA for placeholder
ggmultiplot(plotlist = plots, layout = layout)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.