[R] Use of recordPlot

Mike Prager mike.prager at noaa.gov
Mon Apr 28 19:05:19 CEST 2008


"Beck, Kenneth (STP)" <Kenneth.Beck at bsci.com> wrote:

To be able to page through plots, open the graphics device with
recording turned on before plotting. Then you can use PageUp and
PageDown keys to see the plots in sequence. The plots are stored
into .SavedPlots.  (AFAIK they cannot be accessed with
replayPlot. I don't use that, but I think it is used when a plot
has been saved into a variable with the recordPlot function.)

To enable this sort of session-specific recording, I use the
following code in an script before plotting:

graphics.off()
windows(record = TRUE)
.SavedPlots <- NULL

* The first line closes any open graphics devices.
* The second line opens a new device (here a windows device, but
you could use X11) with plot recording turned on.
* The third line erases any plots already stored in the
plot-recording history. If you don't do this, they will persist
across script runs and even sessions.

You may need to change the code to suit your own needs.

Does that help?

Mike


 
> [...]
> 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. 
> [...]
> 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??

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.



More information about the R-help mailing list