[R] can I add to a plot and auto-re-scale axes?
Duncan Murdoch
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
>axes) ?
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
call.
Your example would look like this:
plot(expts$x[[1]], expts$y[[1]], xlim = range(c(expts$x[[1]],
expts$x[[4]], expts$x[[7]])),
ylim = range(c(expts$y[[1]], expts$y[[4]], expts$y[[7]])))
(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)])
etc.
Duncan Murdoch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
mailing list