[R] Aspect Ratio

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


This example definitely clarified a situation where 'asp' is useful/helpful. Thanks!

On Aug 19, 2010, at 3:05 PM, (Ted Harding) wrote:

Spencer, you came up with your example just as I finished making mine:

 set.seed(54321); X <- rnorm(200) ; Y <- 0.25*X+0.25*rnorm(200)
##Compare:
 plot(X,Y,pch="+",col="blue")
##with:
 plot(X,Y,pch="+",col="blue",asp=1.0)

With R left to choose the X and Y limits by itself, the first
plot gives the superficial impression that Y increases equally
as X increases -- until you look at the scales on the Y and X
axes. Hence it tends to be misleading about how Y depends on X.
The second plot shows their proportional relationship correctly.

Of course you could achive a similar effect by explicitly setting
the X and Y limits yourself:

plot(X,Y,pch="+",col="blue",xlim=c(-2.5,2.5),ylim=c(-2.5,2.5))

but "asp=1.0" saves you the bother of working out what they
should be.

There are, of course, cases where, for the sake of the desired
visual effect, you would want to use an aspect ratio different
from 1. The basic point is that it is a tool to help you get
the vertical and horizontal dimensions of the graph in the
proportions that help to achieve the visual effect you seek.

Ted.

On 19-Aug-10 21:50:12, Spencer Graves wrote:
>        The documentation is not clear.  It would help if it had an 
> example like the following:
> 
> plot(1:2, 1:2/10)
> plot(1:2, 1:2/10, asp=1)
> 
>       Does looking at these two plots answer the question?
>       Spencer Graves
> 
> On 8/19/2010 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.
>> 
> 
> -- 
> Spencer Graves, PE, PhD
> President and Chief Operating Officer
> Structure Inspection and Monitoring, Inc.
> 751 Emerson Ct.
> San José, CA 95126
> ph:  408-655-4567
> 
> ______________________________________________
> 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.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 19-Aug-10                                       Time: 23:05:49
------------------------------ XFMail ------------------------------

______________________________________________
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.



More information about the R-help mailing list