arrangeGrob

0th

Percentile

Arrange multiple grobs on a page

Set up a gtable layout to place multiple grobs on a page.

Usage
arrangeGrob(..., grobs = list(...), layout_matrix, vp = NULL,
  name = "arrange", as.table = TRUE, respect = FALSE, clip = "off",
  nrow = NULL, ncol = NULL, widths = NULL, heights = NULL, top = NULL,
  bottom = NULL, left = NULL, right = NULL, padding = unit(0.5, "line"))

grid.arrange(..., newpage = TRUE)

marrangeGrob(grobs, ..., ncol, nrow, layout_matrix = matrix(seq_len(nrow * ncol), nrow = nrow, ncol = ncol), top = quote(paste("page", g, "of", npages)))

Arguments
...

grobs, gtables, ggplot or trellis objects

grobs

list of grobs

layout_matrix

optional layout

vp

viewport

name

argument of gtable

as.table

logical: bottom-left to top-right (TRUE) or top-left to bottom-right (FALSE)

respect

argument of gtable

clip

argument of gtable

nrow

argument of gtable

ncol

argument of gtable

widths

argument of gtable

heights

argument of gtable

top

optional string, or grob

bottom

optional string, or grob

left

optional string, or grob

right

optional string, or grob

padding

unit of length one, margin around annotations

newpage

open a new page

Details

Using marrangeGrob, if the layout specifies both nrow and ncol, the list of grobs can be split into multiple pages. On interactive devices print opens new windows, whilst non-interactive devices such as pdf call grid.newpage() between the drawings.

Value

arrangeGrob returns a gtable.

marrangeGrob returns a list of class arrangelist

Functions

  • arrangeGrob: return a grob without drawing

  • grid.arrange: draw on the current device

  • marrangeGrob: interface to arrangeGrob that can dispatch on multiple pages

Aliases
  • arrangeGrob
  • grid.arrange
  • marrangeGrob
  • grid.arrange
  • marrangeGrob
Examples
# NOT RUN {
library(grid)
grid.arrange(rectGrob(), rectGrob())
# }
# NOT RUN {
library(ggplot2)
pl <- lapply(1:11, function(.x) qplot(1:10, rnorm(10), main=paste("plot", .x)))
ml <- marrangeGrob(pl, nrow=2, ncol=2)
## non-interactive use, multipage pdf
ggsave("multipage.pdf", ml)
## interactive use; open new devices
ml
# }
Documentation reproduced from package gridExtra, version 2.3, License: GPL (>= 2)

Community examples

Pure-Entropy at Sep 7, 2018 gridExtra v2.3

```{r} #create data `set.seed(0)` if(!file.exists('StormData.csv.bz2')){ download.file('https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2', 'StormData.csv.bz2') } # Read the dataset directly from the compressed file dataset <- read.csv('StormData.csv.bz2', sep = ',') point <- format_format(big.mark = ' ', decimal.mark = '.', scientific = FALSE) # Create a human cost plots with event type counts. hc.fig1 <- ggplot(data = by.event, aes(x = Injuries, y = Fatalities, color = Human.cost)) + geom_count(alpha = 0.64) + ggtitle('Total Human Cost by Event') + scale_color_gradientn('Human Cost', colours = c('green', 'yellow', 'orange', 'red'), guide = 'colourbar') + scale_size(name = 'Number of Events') # Create a mean human cost plot with event type counts. hc.fig2 <- ggplot(data = event.mean, aes(x = Injuries, y = Fatalities, color = Human.cost)) + geom_count(alpha = 0.64) + ggtitle('Mean Human Cost by Event') + scale_color_gradientn('Mean Human Cost', colours = c('green', 'yellow', 'orange', 'red'), guide = 'colourbar') + ylab('Mean Fatalities') + xlab('Mean Injuries') + scale_size(name = 'Number of Events') # Make A figure with the graphs stacked vertivally(nrow = 2). Add a title to the top of the figure(top = ...), and don't open the resulting fig(newpage = F) grid.arrange(hc.fig1, hc.fig2, nrow = 2, newpage = F, top = textGrob('Human Cost Graphs', gp = gpar(fontsize = 15, font = 8)))) ```