base graphics draw directly on a device.
You could use
1- recordPlot
2- the recently introduced gridGraphics
package, to convert base graphics to their grid equivalent
Here's a minimal example,
plot(1:10)
p <- recordPlot()
plot.new() ## clean up device
p # redraw
## grab the scene as a grid object
library(gridGraphics)
library(grid)
grid.echo()
a <- grid.grab()
## draw it, changes optional
grid.newpage()
a <- editGrob(a, vp=viewport(width=unit(2,"in")), gp=gpar(fontsize=10))
grid.draw(a)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…