Re: [R] changing existing graphs optimally

From: Greg Snow <>
Date: Thu 05 Apr 2007 - 14:31:22 GMT

Using traditional and lattice(trellis) graphics, the usual approach is to have your plotting commands in a script file (under windows you can use the one with the GUI, in linux/unix you can have a text editor open with the script). Then either run the commands by copy/paste or using the source function. Then when you see something tha you would like to change, just do the edits and rerun the code.

The ggplot package has some functionality for first specifying the data that you want plotted, then how you want it plotted, then the command to actually create the plot. You can then modify how you want it plotted and replot again.

There are also some interfaces to external programs that work more like what you describe. There is a very basic interface to gnuplot in the TeachingDemos package, the rggobi package interfaces with the ggobi program, there may be others as well.

If you really want to get into deep magic, the recordPlot function returns an object that contains the data and details used in the current plot. However, the way it is stored is subject to change and not always stable, I tried modifying this once to change the range on the axis and ended up crashing R, so I would not suggest that approach. In general it is easier to use my first suggestion rather than delving into the guts of a recorded plot object.

Hope this helps,

Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
(801) 408-8111

> -----Original Message-----
> From:
> [] On Behalf Of projection83
> Sent: Wednesday, April 04, 2007 9:41 PM
> To:
> Subject: [R] changing existing graphs optimally
> hi there,
> right now i am going about things a round about route with
> graphs in that if i want to change the scale to log, I have
> to to a "reset" with add=F, then program things to be redrawn
> from scratch - bad coding basically:P
> in plot(), the first arguement it needs is data - how do you
> reference whats already there, rather than respecifying (or
> am i supposed to use a different function?
> thanks for any pointers!
> --
> View this message in context:
> 9483.html#a9849622
> Sent from the R help mailing list archive at
> ______________________________________________
> mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
______________________________________________ mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code.
Received on Fri Apr 06 00:58:29 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 05 Apr 2007 - 18:30:45 GMT.

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