ggmultiplot: Draw multiple ggplot objects in a single layout

Description Usage Arguments Examples

View source: R/ggplots.R

Description

Uses functions in grid to arrange one or more ggplot objects into a single layout.

Usage

1
ggmultiplot(..., plotlist = NULL, ncol = 1L, layout = NULL)

Arguments

...

ggplot objects

plotlist

list of ggplot objects (optional)

ncol

number of columns in layout

layout

matrix specifying the layout; if present, cols is ignored;

if layout is matrix(c(1, 2, 3, 3), nrow = 2, byrow = TRUE), for example, 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
15
library('ggplot2')
gg <- ggplot(mtcars, aes(factor(1), fill = factor(cyl))) +
  geom_bar(width = 1) + theme_minimal()
gg1 <- gg + coord_polar()
gg2 <- gg + coord_polar(theta = 'y')
gg3 <- ggplot(mtcars, aes(factor(cyl), fill = factor(cyl))) +
  geom_bar(width = 1) + coord_polar() + theme_minimal()

ggmultiplot(gg)
ggmultiplot(gg1, gg2, gg3, ncol = 2)
ggmultiplot(
  gg1, gg2, gg3,
  layout = matrix(c(1, 2, 3, 3, 3, 3), ncol = 2, byrow = TRUE)
)
  

raredd/plotr documentation built on Nov. 13, 2018, 7:05 a.m.