Re: [R] plot() axis problem

About this list Date view Thread view Subject view Author view Attachment view

From: Peter Dalgaard BSA (p.dalgaard@biostat.ku.dk)
Date: Mon 23 Jul 2001 - 20:31:23 EST


Message-id: <x2ae1w543o.fsf@blueberry.kubism.ku.dk>


"Paul Murrell" <p.murrell@auckland.ac.nz> writes:

> 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?

- in S-PLUS you generally get a bunch of warnings for points that run
  off-scale - which presumably would teach you to do it with
  subsetting rather than clipping. (e.g. plot(y~x, subset=x>=a&x<=b))

- the default expressions for xlim/ylim would have to get rather
  complicated: ylim=if(!missing(xlim))range(y[x<=max(xrange) &
  x>=min(xrange)]) (and symmetrically for xlim). I'm not sure we want
  that for something as basic as plot().

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Wed 10 Mar 2004 - 08:18:21 EST