Cairo.onSave | R Documentation |
Cairo.onSave
set the onSave
callback which allows R code
to be run when Cairo finalizes a page (either due to a new page being
created or by the device being closed). The callback expects
function(device, page)
where device
will be the device
number and page
is the currently finished page number (starting
at 1).
Cairo.onSave(device = dev.cur(), onSave)
device |
device number or |
onSave |
function that will replace the current callback or
|
The old callback being replaced or NULL
if there was none.
The function onSave
will be evaluated in the global environment
and no error checking is done, so you must make sure to catch errors,
otherwise the behavior is undefined (and may included crashing R or
other bad things).
Simon Urbanek
Cairo
if (require(png, quietly=TRUE)) {
dev <- Cairo(800, 600, type='raster')
Cairo.onSave(dev, function(dev, page)
.GlobalEnv$png <- writePNG(Cairo.capture(dev))
)
plot(1:10, col=2)
dev.off()
str(png)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.