[R] asp and ylim

David Epstein David.Epstein at warwick.ac.uk
Sun Jul 20 23:58:21 CEST 2008


On 20 Jul, 2008, at 22:00, Rolf Turner wrote:
> 	I just tried
>
> 	 > set.seed(42)
> 	 > x <- runif(10)
> 	 > y <- runif(10)
> 	 > plot(x,y,ylim=c(-1,2),asp=1)
>
> 	and it seemed to give results as expected/desired.
>
> 		cheers,
>
> 			Rolf Turner
>


I tried plot(x,y,ylim=c(0.5,0.7),asp=1) on your data above and it  
failed to restrict the y-coordinates to between 0.5 and 0.7.  In  
fact, the behaviour is independent of whether I insert the ylim=c 
(0.5,0.7) argument or omit it. So that's definitely not what I want  
to happen. Nor does the behaviour accord with the advertised  
behaviour seen from help(plot.window). I want the smallest y-coord  
seen on the plot to be .5 and the largest to be .7. I want points  
outside that range not to be displayed. This seems to be what help 
(plot.window) promises.

When I added to your plot command the argument xlim=c(0,1), then that  
xlim instruction was also ignored. It seems that there is an unstated  
set of rules for how the plot should react to xlim and ylim settings  
when asp is set. I wonder if anyone knows what they are. I suppose  
one could always read the source. For example, one might guess from  
these examples discussed so far that asp=1 forces the forces the  
window to be square, but that is not the case. And the command plot 
(x,y,xlim=c(-6,-1),ylim=c(-1,2),asp=1) on your data suddenly decides  
that it ought to behave the way I think is reasonable---namely the  
plot is empty---in contrast to all the other examples where it has  
insisted on displaying ALL the points (x[i],y[i]), ignoring the  
values of xlim and ylim.

It's fine by me to have xlim and ylim perform idiosyncratically. But  
can I achieve the degree of control I would like, perhaps using a  
different technique, or different tags?

David



More information about the R-help mailing list