Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

capture_base_plot

Capture a base plot


Description

Capture a plot drawn using base graphics as a grid grob.

Usage

capture_base_plot(expr)

Arguments

expr

A expression that draws a plot using base graphics.

Value

An object of class gTree.

Note

A side effect of this function is that plots get drawn twice: once as a base plot, and secondly as a grid plot.

References

Graumann, J., and Cotton, R.J. (2018). multipanelfigure: Simple Assembly of Multiple Plots and Images into a Compound Figure. Journal of Statistical Software 84. doi: 10.18637/jss.v084.c03

See Also

Examples

p <- capture_base_plot(hist(rnorm(1000), seq(-4, 4, 0.2)))
grid::grid.draw(p)
# If the plot takes multiple lines to draw, then wrap the code in braces.
p2 <- capture_base_plot({
  par(las = 1)
  plot(1:5)
  title("One to five")
})
grid::grid.draw(p2)

multipanelfigure

Infrastructure to Assemble Multi-Panel Figures (from Grobs)

v2.1.2
GPL (>= 3)
Authors
Johannes Graumann [cre, aut], Richard Cotton [ctb]
Initial release
2020-03-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.