[R] Aspect ratio and limits
Barry Rowlingson
B.Rowlingson at lancaster.ac.uk
Tue Apr 19 17:28:49 CEST 2005
Suppose I have the following data I want to scatterplot:
> xy
[,1] [,2]
[1,] 0 0
[2,] 21 4
I start up a graphics window and fire away:
> plot(xy)
- but because the graphics window is square, the aspect ratio is
wrong. So I add:
> plot(xy, asp=1)
- now the aspect ratio is correct, but the Y range is about -8 to 11,
whereas my data has a Y range of 0 to 4. The plot appears in the middle
of a mostly empty square. So lets try:
> plot(xy, asp=1, ylim=c(0,4))
- which seemingly changes nothing. The reason being that par()$pty is
'm', which means to use as much of the plot area as possible. The only
other option is 's' which produces a square plot. I want it to produce a
very rectangular plot. R cant comply with all these requests.
If I leave par(pty='m') then I can change the shape of the graphics
window until I get the effect I want, but this seems an unsatisfactory
way of doing it, and when I come to make a PostScript version I need to
set the dimensions of the PS device correctly.
Is there a right way to do this? The only way I can think is to do the
plot without box and axes, and then add them afterwards, but that could
get very messy. Have I missed something obvious?
Barry
More information about the R-help
mailing list