Learn R Programming

grDevices (version 3.6.2)

recordPlot: Record and Replay Plots

Description

Functions to save the current plot in an R variable, and to replay it.

Usage

recordPlot(load=NULL, attach=NULL)
replayPlot(x, reloadPkgs=FALSE)

Arguments

load

If not NULL, a character vector of package names, which are saved as part of the recorded plot.

attach

If not NULL, a character vector of package names, which are saved as part of the recorded plot.

x

A saved plot.

reloadPkgs

A logical indicating whether to reload and/or reattach any packages that were saved as part of the recorded plot.

Value

recordPlot returns an object of class "recordedplot".

replayPlot has no return value.

Warning

The format of recorded plots may change between R versions, so recorded plots should not be used as a permanent storage format for R plots.

As of R 3.3.0, it is possible (again) to replay a plot from another R session using, for example, saveRDS and readRDS. It is even possible to replay a plot from another R version, however, this will produce warnings, may produce errors, or something worse.

Details

These functions record and replay the displaylist of the current graphics device. The returned object is of class "recordedplot", and replayPlot acts as a print method for that class.

The returned object is stored as a pairlist, but the usual methods for examining R objects such as deparse and str are liable to mislead.

See Also

The displaylist can be turned on and off using dev.control. Initially recording is on for screen devices, and off for print devices.