multipanelfigure (version 2.1.2)

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.

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

grid.echo, grid.grab

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab