[R] Aspect Ratio

r.ookie r.ookie at live.com
Fri Aug 20 00:09:59 CEST 2010


I understand Joshua, it's a way to display the plotted data in a graph. I've been using 'ylim = c()' and 'xlim = c()' so far but it's nice to be aware of 'asp' too.

On Aug 19, 2010, at 2:58 PM, Joshua Wiley wrote:

On Thu, Aug 19, 2010 at 2:46 PM, r.ookie <r.ookie at live.com> wrote:
> I'm asking to get people's interpretation and also whether they've encountered situations where it was useful, helpful, etc.

In general, it would probably help your responses on this list if you
were clearer in the first place then.  For instance, "In the
documentation I read that 'asp' is _____, but I have tried x and y I
do not understand when it would be helpful to set 'asp' to values
other than the default".

Imagine you have two variables, X and Y.  X has a very small range
(lets say a probability of having an accident) and Y has a huge range
(number of kilometers driven in a year).  Setting different aspect
ratios, may make it easier to see the data.  What follows are some
examples.  The y axis data is the same in all four, but I there are
two sets of data for the x axis.  You can see how setting different
aspect ratios makes the relationship between X and Y more or less
clear.

####################
x1 <- seq(from = 0, to = .1, by = .01)
x2 <- seq(from = 0, to = 1000, by = 100)
y <- 0:10
# so that four plots can be in one window for comparison
par(mfcol=c(2,2))

# Make the four plots with a variety of aspect ratios
plot(x = x1, y = y, asp = 1/1,
    main = expression(paste(frac(y, x) == frac(1, 1))))
plot(x = x1, y = y, asp = 1/100,
    main = expression(paste(frac(y, x) == frac(1, 100))))
plot(x = x2, y = y, asp = 1/1,
    main = expression(paste(frac(y, x) == frac(1, 1))))
plot(x = x2, y = y, asp = 100/1,
    main = expression(paste(frac(y, x) == frac(100, 1))))

###################

> 
> On Aug 19, 2010, at 2:36 PM, David Winsemius wrote:
> 
> 
> On Aug 19, 2010, at 5:28 PM, 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?
> 
> It yet again appears that you are asking us to read the help pages for you.
> 
> 
>> 
>> 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?
>> 
>> --
> 
> David Winsemius, MD
> West Hartford, CT
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list