gglayout: Prints ggplot graphics in grid layout.

Description Usage Arguments Details Examples

View source: R/spanner.R

Description

Takes a list of ggplot objects and prints these using a grid layout supplied by grid.layout. In this way, a list of plots can be laid out in complex ways on the screen.

Usage

1
2
3
  gglayout(plotList,
    layout = grid.layout(1, length(plotList)),
    colwise = TRUE, rowwise = !colwise)

Arguments

plotList

A list of ggplot objects

layout

A layout provided by grid.layout

Details

The plotsin plotList are printed sequentially to the viewports defined by layout, in order of rows followed by columns. If an element of plotList is NULL, then that plot is empty.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
require(ggplot2)
require(grid)
p <- ggplot(mtcars, aes(factor(cyl)))
pList <- list(
    p + geom_bar(),
    NULL,
    p + geom_bar() + coord_flip(),
    p + geom_bar(fill="white", colour="darkgreen")
)

gglayout(pList)
gglayout(pList, layout=grid.layout(4, 1))
gglayout(pList, layout=grid.layout(1, 4))
gglayout(pList, layout=grid.layout(2, 2), rowwise=TRUE)

andrie/spanner documentation built on June 3, 2017, 7:03 p.m.