R-beta: Switching between plots without erasing them.
ihaka at stat.auckland.ac.nz
Tue Jul 1 05:43:47 CEST 1997
Richard Lammers writes:
> I originally sent this to the list a week ago. Should I assume the lack
> of response was due to an inappropriate question, or that this cannot be
Perfectly appropriate. I'm the person largely guilty of perpertrating
the R graphics software, and I've been out sick.
> ---------- Forwarded message ----------
> Date: Sat, 21 Jun 1997 11:09:21 -0400 (EDT)
> From: Richard Lammers <lammers at edac.sr.unh.edu>
> To: r-help at stat.math.ethz.ch
> Subject: R-beta: Switching between plots without erasing them.
> I have a question relating to switching between plots within the graphics
> window [x11()]. If this is not appropriate for this mailing list then
> please let me know.
> What I am doing now:
> Opening a graphics window and setting two plot regions [ie with
> par(mfrow=c(2,1))]. In the top section there is a plot with a set of
> points which represent river gauges located by latitude and longitude
> pairs. These points are global in extent so I am also using continent
> boundaries from a data set found on Statlib. Because there are so many
> points this takes some time to draw. Using the identify() function a
> point is selected and in the lower plot a time series is displayed from
> that particular river gauge. This is in a loop which allows repeated
> clicks on the map and time series plots. Each time through the loop, the
> map must be redrawn.
> I would like to do the following:
> I would like to keep the upper plot (the map) intact while being able to
> completely redraw the lower plot (the time series). Is there some way I
> can return to the upper plot and invoke the identify function without
> erasing the map? The function frame() erases the plot. I suppose the
> alternative would be to have two independent graphics windows, but I am
> not sure if that is possible within R.
Hmmm. This should certainly be possible. There are two possible
a) use par(mfrow=c(2,1)) and then manually set the graph
you want to work in using par(mfg=...)). This appears to be
broken, but I will fix it.
b) Set the plotting region explicitly using par(fig=...)
# Set up upper plot
# do upper plot
save.usr <- par("usr")
# Reset upper plot
# identify upper point using "locator"
# break if outside "usr" bounds
# Set up lower plot
# erase the entire lower figure
# this will be a little tricky
# it might be best to write a new
# graphics function "erase"
# I will think about this.
# do new plot
This is a partial way to proceed. It might be possible to figure out
how to erase the lower region using par("usr") and par("plt"), but it
would be trivial to add a new "erase" primitive.
I will think about this some more and should have some code soon.
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help