[R] Aspect Ratio

Gavin Simpson gavin.simpson at ucl.ac.uk
Fri Aug 20 00:18:03 CEST 2010


On Thu, 2010-08-19 at 14:28 -0700, r.ookie wrote:
> Well, I had to look further into the documentation to see 'If asp is a
> finite positive value then the window is set up so that one data unit
> in the x direction is equal in length to asp * one data unit in the y
> direction'
> 
> Okay, so in what situations is the 'asp' helpful?

If 'x' and 'y' are in the same units but one covers a larger/smaller
range than the other, asp will make the axes be scaled in the same units
such that the distance along the 'y' axis for 1 unit change is the same
as the distance along the 'x' axis for a 1 unit change.

dat <- data.frame(x = seq(1, 100, length = 100),
                  y = seq(1, 10, length = 100))

layout(matrix(1:2, ncol = 2))
plot(y ~ x, data = dat)
plot(y ~ x, data = dat, asp = 1, main = expression(asp == 1))
layout(1)

If x and y are both in say metres the second plot respects the natural
scale whereas the first doesn't.

G

> 
> On Aug 19, 2010, at 2:24 PM, David Winsemius wrote:
> 
> 
> On Aug 19, 2010, at 5:13 PM, r.ookie wrote:
> 
> > set.seed(1)
> > x <- rnorm(n = 1000, mean = 0, sd = 1)
> > plot(x = x, asp = 2000)
> > 
> > Could someone please explain what the 'asp' parameter is doing?
> 
> You want us to read the help page to you?
> 

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list