ggmultiplot: Draw multiple ggplot objects in a single layout

View source: R/ggplots.R

ggmultiplotR Documentation

Draw multiple ggplot objects in a single layout

Description

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

Usage

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

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. 19, 2023, 4:09 a.m.