Skip to content
Prev 68048 / 398506 Next

Aspect ratio and limits

On Tue, 2005-04-19 at 16:28 +0100, Barry Rowlingson wrote:
Here is one possibility that could be used for both your X11 and
postcript devices. Using your small dataset 'xy' for this example:

xy <- matrix(c(0, 21, 0, 4), ncol = 2)
[,1] [,2]
[1,]    0    0
[2,]   21    4


# Get ratio of width to height
aspect <- diff(range(xy[, 1])) / diff(range(xy[, 2]))

# Set height value as you require
height <- 3
X11(width = aspect * height, height = height)

# Now plot
plot(xy, asp = 1)


#For postscript
height <- 3
postscript(width = aspect * height, height = height, 
           onefile = FALSE, paper = "special",
           horizontal = FALSE)
plot(xy, asp = 1)
dev.off()


You can of course, adjust the height value to your desire or reverse the
computation to allow you to specify the width, etc.

Does that get you what you need?

HTH,

Marc Schwartz