set_panel_size: Set panel size

View source: R/ggplots.R

set_panel_sizeR Documentation

Set panel size

Description

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

Usage

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

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