[R] setting xlim and ylim with asp=1

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Aug 25 13:31:58 CEST 2003


On Mon, 25 Aug 2003, Angel wrote:

> In plot(), when using option asp=1 the xlim and ylim have no effect because
> they are changed
> changed in order to fill the whole plot region. 

Not true: try xlim=c(-2,2) in your example.

> Is there a way to
> automatically set
> xlim and ylim when asp has been set to 1?
> For example:
> #This is a box of the plot ranges I want:
> boxxy=rbind(c(-1,2),c(-1,-1),c(1,-1),c(1,2),c(-1,2))
> #Without asp=1 I get what I want (i.e. I can't see the box because it
> #overlays with the axis
> plot(boxxy,type="l",xaxs="i",yaxs="i",xlim=c(-1,1), ylim=c(-1,2))
> # When I add asp=1 I can see the box
> plot(boxxy,type="l",xaxs="i",yaxs="i",xlim=c(-1,1), ylim=c(-1,2),asp=1)

And you must be able to, since the plot region is not in ratio 2:3 on any
standard graphics device.

R is doing sensible things, and you have not told us what you want, just 
made a false assertion.  Perhaps you could try to explain what it is you 
actually want to do?

You cannot set the aspect ratio, the plot region and xlim and ylim
simultaneously: once you have three the fourth is (partially) determined.
I suspect you intended to set the plot region ... see An Introduction to
R.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list