ggmultiplot: Multiple plot function, accepts a list of ggplot (not plot)...

View source: R/plot.R

ggmultiplotR Documentation

Multiple plot function, accepts a list of ggplot (not plot) objects

Description

Multiple plot function, accepts a list of ggplot (not plot) objects

Usage

ggmultiplot(
  ...,
  plotlist = NULL,
  cols = NULL,
  layout = NULL,
  title = "",
  title.size = 20
)

Arguments

plotlist

objects can be passed in ..., or to plotlist (as a list of ggplot objects) (p1,p2,p3), (plotlist=list(p1,p2,p3)), or (p1,plotlist=list(p2,p3))

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.

title

string, NULL or ” both fine
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.

Value

returns nothing (NULL)

References

Cookbook R

Examples

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)


jerryzhujian9/ezmisc documentation built on March 9, 2024, 12:44 a.m.