View source: R/capture_base_plot.R
capture_base_plot | R Documentation |
Capture a plot drawn using base graphics as a grid grob
.
capture_base_plot(expr)
expr |
A expression that draws a plot using base graphics. |
An object of class gTree
.
A side effect of this function is that plots get drawn twice: once as a base plot, and secondly as a grid plot.
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
grid.echo
, grid.grab
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.