plot_layout - janeshdev/ggplot2 GitHub Wiki

Illustration of the various elements of a ggplot. The names are taken from the corresponding opts() parameters. layout

TODO:

(work in progress)

  • comprehensive list of all opts()
  • use gridSVG and tooltips instead of static annotations.

Original code:

library(ggplot2)
p <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) + geom_point() + facet_grid(vs ~ am, scales = "free") +
  opts(title="Title",  panel.margin=unit(2, "line"), plot.margin = unit(rep(3, 4), "lines"))

vp <- viewport(width=0.9, height=0.9)
grid.newpage()
print(p, vp=vp)
grid.rect(vp=vp, gp=gpar(lty=2))