[R] can I add to a plot and auto-re-scale axes?
dmurdoch at pair.com
Mon Oct 1 13:34:26 CEST 2001
On Sun, 30 Sep 2001 22:06:47 -0400 (EDT), you wrote:
>(I'm new to R)
>Is there a way to add data to an existing plot, and have the plot axes
>rescaled automatically (i.e. if the new data lie outside the current
No, there's not. The scale is established by the first call.
>If not, how can I specify multiple datasets at once, so the axes are
>scaled to accomodate all sets?
You need to use the optional arguments xlim and ylim in the first
Your example would look like this:
plot(expts$x[], expts$y[], xlim = range(c(expts$x[],
ylim = range(c(expts$y[], expts$y[], expts$y[])))
(You might make do with something much simpler, like xlim = c(0,10),
if you know the range of the data in advance, or want consistency
across a wider range.)
You also asked whether your data was organized well. I'd suggest not
using a list, just use single x and y vectors, with another vector
giving the experiment number. Then you could have something like
plot(x[expt == 1], y[expt == 1], xlim = range(x[expt %in% c(1,4,
7)]), ylim = range(y[expt %in% c(1,4, 7)])
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