multiplot: Plot multiple ggplot objects

Description Usage Arguments Examples

View source: R/CalcStatCont.R

Description

ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects) This code has been borrowed from http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/

Usage

1
multiplot(..., plotlist = NULL, cols = 1, layout = NULL)

Arguments

...

: other arguments.

plotlist

List: A list of all plots

cols

Numeric: Number of columns in layout

layout

Matrix: specifying the layout. If present, 'cols' is ignored. 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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
df <- data.frame(colA = seq(1:1000), colB = seq(1000,1))
p1 <- ggplot2::ggplot(df, ggplot2::aes(x = colA, y = colB)) + 
ggplot2::geom_point(ggplot2::aes(size = colA))
p2 <- ggplot2::ggplot(df, ggplot2::aes(x = colA, y = colB)) + 
ggplot2::geom_point(col = "red")
p3 <- ggplot2::ggplot(df, ggplot2::aes(x = colA, y = colB)) + 
ggplot2::geom_line()
multiplot(p1,p2,p3, cols =2)
multiplot(plotlist = list(p1,p2,p3), cols =2)
multiplot(plotlist = list(p1,p2,p3), layout = matrix(c(1,2,3,3), nrow =2))
multiplot(plotlist = list(p1,p2,p3), layout = matrix(c(1,2,3,3), nrow=2, byrow=TRUE))

## End(Not run)

NCAR/rwrfhydro documentation built on Feb. 28, 2021, 12:47 p.m.