[R] plot: how to fix the ratio of the plot box?

Hofert Jan Marius marius.hofert at math.ethz.ch
Sun Oct 2 10:20:55 CEST 2011

Dear all,

this should be trivial, but I couldn't figure out how to solve it... I would like to have a plot with fixed aspect ratio of 1. Whenever I resize the Quartz window, the axes are extended so that the plot fills the whole window. However, if you have different extensions for the different axes, the plot does not look  like "a square" anymore (i.e., aspect ratio 1). The same of course happens if you print it to .pdf (ultimate goal). How can I fix the plot box (formed by the axes) ratio to be 1, meaning that the plot box is a square no matter how I resize the Quartz window?

I searched for this and found: http://tolstoy.newcastle.edu.au/R/help/05/04/2888.html
It is more or less recommended to use lattice's xyplot for that. Is there no solution for base graphics?
[I know that the extension is by default 4% and that's great, but the the size of the Quartz window should not change this (which it does if you resize the window accordingly)].



Minimal example:
u <- runif(10)
pdf(width=5, height=5)
plot(u, u, asp=1, xlim=c(0,1), ylim=c(0,1), main="My title")

More information about the R-help mailing list