Skip to content

plot_layout

Mara Averick edited this page Nov 2, 2018 · 2 revisions

Note: The ggplot2 wiki is no longer maintained, please use the ggplot2 website instead!

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))

Note: The ggplot2 wiki is no longer maintained, please use the ggplot2 website instead!

Clone this wiki locally