set_panel_size: Set panel size

Description Usage Arguments Author(s) References Examples

View source: R/ggplots.R

Description

Use strict size for panels when number of panels in rows/columns are not equal.

Usage

1
2
set_panel_size(p = NULL, file = NULL, margin = unit(1, "cm"),
  width = unit(4, "cm"), height = unit(4, "cm"))

Arguments

p

a ggplot object

file

optional file name if result should be saved to file, passed to ggsave

margin

a unit object giving the plot margins

width, height

a unit object giving height and width for each plot

Author(s)

Baptiste Auguie

References

SO question

Examples

1
2
3
4
5
6
7
8
9
library('ggplot2')
library('gridExtra')
p1 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_wrap(~ vs)
p2 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_wrap(~ gear)
grid.arrange(p1, p2)

g1 <- set_panel_size(p1)
g2 <- set_panel_size(p2)
grid.arrange(g1, g2)

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