[R] plot() axis problem

Jim Lemon bitwrit at ozemail.com.au
Mon Jul 23 09:20:23 CEST 2001

Paul Murrell wrote:
> ...Any other arguments for or against?

It depends upon how you interpret the request to plot().  

1) Plot the first 10 values of each of two 20 element numeric vectors
against each other (i.e. plot(x[1:10],y[1:10])) and the result is
probably what is wanted.

2) Plot two 20 element numeric vectors against each other, but limit the
range of the plot on one set of values (i.e. plot(x,y,xlim=c(1,10))) -
which plot() does, but without calculating the revised range for the
values that will be _visible_.

The example uses a rather artificial dataset, neatly divided into
monotonically increasing low and high values.  Any permutation of those
values that did not fall into that pattern would render the question
meaningless.  For example, try


If the range condition is to be applied, perhaps it should be as:

plot(x[x>=1 & x<=10],y[x>=1 & x<=10])

I think the present behavior of plot() is pretty sensible.

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