This posting just illustrates the problem with plot() x<-1:20 y<-c(1:10,301:310) plot(x,y) xrange<-c(1,10) plot(x,y,xlim=xrange) #uses ylim=range(y) This is the default behaviour of plot() and I think it is not sensible. By default the range of the y axis should span the y values corresponding to the points plotted. In this example the yaxis should span 1-10 rather than 1-310. This does the sensible thing: plot(x,y,xlim=xrange,ylim=range(y[x<=max(xrange) & x>=min(xrange)])) I suggest that plot() changes to this default behaviour. Bill -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi> This posting just illustrates the problem with plot() > > x<-1:20 > y<-c(1:10,301:310) > plot(x,y) > xrange<-c(1,10) > plot(x,y,xlim=xrange) #uses ylim=range(y) > This is the default behaviour of plot() and I think it is not sensible. > By default the range of the y axis should span the y values corresponding > to the points plotted. In this example the yaxis should span 1-10 rather > than 1-310. This does the sensible thing: > > plot(x,y,xlim=xrange,ylim=range(y[x<=max(xrange) & x>=min(xrange)])) > > I suggest that plot() changes to this default behaviour.The only objections I can think of so far concern (backward) compatibility: (i) R currently does what S-Plus does -- that helps portability of S code (ii) If we made this change then users' existing R code might start behaving differently The second problem is a fairly significant one I think -- it is impossible to check for all instances and the change would be potentially quite dramatic. Perhaps you could argue that it would be sufficiently rare ...? Any other arguments for or against? Paul -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 y<-c(1,301,2,3,4,5,6,7,8,9,10,302:310) plot(x,y,xlim=c(1,10)) 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. Jim -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._