Re: [R] asp and ylim

From: David Epstein <>
Date: Sun, 20 Jul 2008 22:58:21 +0100

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 mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sun 20 Jul 2008 - 22:04:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 20 Jul 2008 - 22:31:49 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive