[R] changing existing graphs optimally

Greg Snow Greg.Snow at intermountainmail.org
Thu Apr 5 16:31:22 CEST 2007


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
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of projection83
> Sent: Wednesday, April 04, 2007 9:41 PM
> To: r-help at stat.math.ethz.ch
> 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: 
> http://www.nabble.com/changing-existing-graphs-optimally-tf352
> 9483.html#a9849622
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list