[R] Use of recordPlot

Greg Snow Greg.Snow at imail.org
Tue Apr 22 17:42:32 CEST 2008


You seem to be confusing several issues.

First, being object oriented does not mean that it matches C++ syntax or
that every object is guarenteed to have specific methods.  What lead you
to think that a recordedplot would have a metafile method?  Nothing else
has that method, and the only function I find with metafile is the
win.metafile graphics device.

The difference between SavedPlots and recordedPlot is the same as the
difference between "flock" and "sheep" when talking about a flock of
sheep.  A recordedPlot object is a single plot, a SavedPlots object is a
group of recordedPlot objects (not the plural vs. singular).

Look at the help for "objects" or "ls" (?ls) and look at the 'all.names'
argument to see how to find .SavedPlots

R does not use object.method for method dispatch, trying that is
confusing the parser and that is why you get an error.  Try
method(object) instead.

Also recognize that R follows the philosophy of "Source is Real". For
what you are trying to do, it will probably work better to write a
script or function that creates your plots, then rerun the code when you
want the plots again.  The current mechanism is useful for a quick
paging through plots, but was not meant for much more.  


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Beck, Kenneth (STP)
> Sent: Monday, April 21, 2008 4:10 PM
> To: r-help at r-project.org
> Subject: [R] Use of recordPlot
> 
> 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