[R] Use of recordPlot

Beck, Kenneth (STP) Kenneth.Beck at bsci.com
Tue Apr 22 00:09:30 CEST 2008


I am trying to save plots that I create using calls to windows() folowed
by multiple calls to plot to place several plots on a page. I want to
store the plots as variables to be able to recall them later. 
The documentation states:
"Recorded plot histories are of class "SavedPlots". They have a print
method, and a subset method. 
As the individual plots are of class "recordedplot" they can be replayed
by printing them: see recordPlot. 
The active plot history is stored in variable .SavedPlots in the
workspace."

But what does this mean "class SavedPlots"? Is class similar to a class
in C++? 
Where are the plot() and metafile(), etc methods for this class? 
And if it is saved as a SavedPlots class, then what is a "recordedplot"
class? 
Why the two names? Finally, the .SavedPlots does not appear in my
workspace at all. 
Where did it go?

Here is a code snippet, why does this not work:
windows();
nf1 <- layout(matrix(1), widths=lcm(6), heights=lcm(6))
par(mfrow=c(2,2));
par (mfg=c(1,1));
plot( ...some stuff...);
par (mfg=c(1,2);
plot(....some more stuff...)
par (mfg=c(2,1);
plot(....some more stuff...)
par (mfg=c(2,2);
plot(....some more stuff...)

plot_save=recordPlot();

# now some more code, doing other stuff, maybe more plots
# now try to replay the saved plot:

replayPlot(plot_save)

This last line gives the following error:
Error in replayPlot(plot_save) : 
  A clipboard metafile can store only one figure.

The documentation says that replayPlot() has a print method, so let's
try that: we get the following error:
Error: unexpected symbol in "replayPlot(lm_hr_plot).print"

Can someone help me understand this, and get routines to save and replay
plots? 

Thanks in advance...


More information about the R-help mailing list