Re: [R] Use of recordPlot

From: Greg Snow <>
Date: Wed, 30 Apr 2008 12:55:59 -0600

My impression of the plot recording in windows was that it was a quick tool to be useful, but not a high priority. Trying to keep track of 50 plots (and using different plot windows) is pushing it beyond its original intention. I expect that he core people have higher priorities, so may not even want to look at it for a while.  

If you want to be able to scroll through 50 or so plots made by a script, I would suggest using the pdf device (or postscript) to write them all to a file, then open the file and use pgup/pgdn to scroll through the graphs. This is a couple of extra steps, but I think it will work better for you at this point.

From: Beck, Kenneth (STP) [] Sent: Mon 4/28/2008 8:53 AM
To: Greg Snow;
Subject: RE: [R] Use of recordPlot

Thanks for the clarification, this helps a lot, expecially your comment about "source is real". I will stop my effort to save the graphs permanently, the scripts don't take long to generate.

But the end of your response hits on the key issue: when I create several graphs, I would like to be able to use PgUp/PgDn or some other keystroke to easily scroll through them all in sequence. One of my scripts now creates 30+ graphs, and to view them I have to mouse to the list of graphics devices and pick off the list. Your last comment indicates you can set it up to quick page through lists of graphs. I just tried adding options(graphics.record=TRUE); to my code, and I now find the .SavedPlots variable in the work space, but I was hoping to use replayPlot(.SavedPlots) or something like that to be able to scroll through the plots, but it does not seem to work.

Why do I not get anything when I ask for help (?.SavedPlots)?

Does this variable contain only those plots for which I call recordPlot? At times it seems yes (e.g. only a few plots), but then later it seemed to contain all that were generated by the script (nearly 50). When I pick Previous/Next Plot or use PgUp/PgDn when viewing a graphcis Device, the title bar stays on the latest graphics Device number, though the graph itself may change. But then on further PgUp, I see only the layout, not the graph.

When I use commands in the console to attempt to show graphs, I get a warning suggesting the graph was saved in an older format, but I have the latest R installed (2.6.2):

.SavedPlots[2] or replayPlot(.SavedPlots[2]) Warning message:
In replayPlot(x) : loading snapshot from pre-2.0.0 R version

Is there a simple command or series of commands to add to the script to enable scrolling through all plots generated by that script? Or maybe something at the beginning with something else at the end??

Thanks for your help...

-----Original Message-----
From: [] On Behalf Of Greg Snow
Sent: Tuesday, April 22, 2008 10:43 AM
To: Beck, Kenneth (STP); Subject: Re: [R] Use of recordPlot

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
(801) 408-8111

> -----Original Message-----
> From:
> [] On Behalf Of Beck, Kenneth (STP)
> Sent: Monday, April 21, 2008 4:10 PM
> To:
> 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...
> ______________________________________________ mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ______________________________________________ mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code.
Received on Wed 30 Apr 2008 - 19:07:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 01 May 2008 - 08:30:34 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive