multiplot: Plot several ggplot objects in one device

View source: R/functions.R

multiplotR Documentation

Plot several ggplot objects in one device

Description

mulitplot prints several ggplot plot-objects on one device

Usage

multiplot(..., plotlist = NULL, cols = 1, layout = NULL, titles = NULL,
  widths = NULL, heights = NULL)

Arguments

...

Several ggplot objects that should be placed on the same plotting device

plotlist

Optional - a list of ggplot objects to be placed on the same plotting device

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

Details

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.

Note

Original code was taken from R Graphics Cookbook courtesy of Winston Change http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/

Author(s)

Florian Klinglmueller float@lefant.net, Winston Chang

References

Chang, W. (2012). R graphics cookbook. O'Reilly Media, Inc.

Examples


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)


floatofmath/bt88.03.704 documentation built on March 25, 2022, 12:28 p.m.