Re: [R] aspect ratio 1 and blank space

2010-11-18 Thread Greg Snow
Look at the squishplot function in the TeachingDemos package, it may do what 
you want, or if not quite then you could perhaps tweak the code to include the 
values you want and create the correct aspect ratio.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Silvia Cecere
 Sent: Wednesday, November 17, 2010 10:26 AM
 To: r-help@r-project.org
 Subject: [R] aspect ratio 1 and blank space
 
 
 Hi,
 I need to produce an ordinary scatter plot and it is vital that the
 aspect ratio equals 1.
 
 I set the axis as:
 
 plot(x, y, type=n, asp=1, ,ylim=c(-80,70),xlim=c(0,100)).
 
 The problem is that I get some 'additional' blank plot area (basically,
 the lower bound of xlim becomes quite negative).
 
 The xlim is not the range of the x-data,  but I need the 0 there for
 further plotting.
 
 
 Any way to specify that even with asp=1,  xlim=c(0,100)?
 
 Thanks,
 
 __
 R-help@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.

__
R-help@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.


Re: [R] aspect ratio 1 and blank space

2010-11-17 Thread Bert Gunter
On Windows R 2.12.0, the following seemed to work for me:

par(pty=s)  ## before plotting
plot(1:10,xlim=c(0,20),ylim=c(0,30))

I do not find that setting the asp parameter does anything useful;
indeed, the Help documentation seems to be backwards (asp=x/y not
y/x).  I probably misunderstood and/or misused it, though -- asp seems
to interact with the xlim and ylim settings in inscrutable ways ... on
Windows, anyway.

HTH.

Cheers,
Bert

On Wed, Nov 17, 2010 at 9:26 AM, Silvia Cecere scec...@yahoo.com wrote:

 Hi,
 I need to produce an ordinary scatter plot and it is vital that the aspect 
 ratio equals 1.

 I set the axis as:

 plot(x, y, type=n, asp=1, ,ylim=c(-80,70),xlim=c(0,100)).

 The problem is that I get some 'additional' blank plot area (basically, the 
 lower bound of xlim becomes quite negative).

 The xlim is not the range of the x-data,  but I need the 0 there for further 
 plotting.


 Any way to specify that even with asp=1,  xlim=c(0,100)?

 Thanks,

 __
 R-help@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.




-- 
Bert Gunter
Genentech Nonclinical Biostatistics

__
R-help@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.


Re: [R] aspect ratio 1 and blank space

2010-11-17 Thread Peter Ehlers

On 2010-11-17 09:26, Silvia Cecere wrote:


Hi,
I need to produce an ordinary scatter plot and it is vital that the aspect 
ratio equals 1.

I set the axis as:

plot(x, y, type=n, asp=1, ,ylim=c(-80,70),xlim=c(0,100)).

The problem is that I get some 'additional' blank plot area (basically, the 
lower bound of xlim becomes quite negative).

The xlim is not the range of the x-data,  but I need the 0 there for further 
plotting.


Any way to specify that even with asp=1,  xlim=c(0,100)?


It's not clear (to me, at least) what exactly you want to achieve.
An aspect ratio of 1 means that you want the x-scale and the y-scale
to be equal. The default plot window has dimensions
height = width = 7 in, leading to a plot that's roughly square and
onto which you want to place an x-scale of extent 100 units and a
y-scale of extent 150 units. It's clear that equal units on both
axes are going to lead to some 'extension' of the xlims. If you
want to avoid that, you'll have to specify different height/width
values, something like:

 x11(height = 7, width = 7 * (100 - 0)/(70 + 80))

and then place your plot call. You might also want to set the
xaxs and/or yaxs parameters.

  - Peter Ehlers



Thanks,

__
R-help@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.


__
R-help@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.


Re: [R] Aspect Ratio

2010-08-23 Thread Greg Snow
A couple of additional examples of when asp is important to use:

The command abline(0,1) adds a line to the current plot, this line is often 
referred to as the 45 degree line, but the angle with the axes is only 45 
degrees when asp==1, setting asp=1 will enforce this.

There are multiple packages that produce maps relating to real world geography. 
 These maps look really funny (and not related to real world geography) if they 
are allowed to fill the available graph space rather than enforcing an 
appropriate aspect ratio (usually not 1).

William Cleveland did research showing that many plots are easier to interpret 
when the aspect ratio is set so that the average angle of the absolute value of 
lines of interest is 45 degrees.  Compare the following 2 plots (look at how 
fast the sunspots increase vs. how fast they decrease):

plot(sunspots, type='l')
plot(sunspots, type='l', asp=1/10)

Another function to look at if you don't want all the white space inside of the 
plot is the squishplot function in the TeachingDemos package.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of r.ookie
 Sent: Thursday, August 19, 2010 3:29 PM
 To: David Winsemius
 Cc: r-help@r-project.org
 Subject: Re: [R] Aspect Ratio
 
 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?
 
 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@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.

__
R-help@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.


Re: [R] Aspect Ratio

2010-08-23 Thread Peter Ehlers

On 2010-08-19 16:36, r.ookie wrote:

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



Ted's last example is a bit misleading. You don't get the same
result from setting xlim and ylim equal as you do from using 'asp'.
Indeed, this should help you to understand aspect ratio even
better.

Try this:

 x11(width = 10, height = 5)
 plot(X,Y,pch=+,col=blue,xlim=c(-2.5,2.5),ylim=c(-2.5,2.5))

(using Ted's X,Y) and compare with the 'asp' version.

  -Peter Ehlers


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@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@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.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 19-Aug-10   Time: 23:05:49
-- XFMail --



__
R-help@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.


Re: [R] Aspect Ratio

2010-08-19 Thread Joshua Wiley
Hi,

From the documentation for ?plot  'asp' the y/x aspect ratio, see
'plot.window'.  Here is a little demonstration of what different
values would look like:

#
set.seed(1)
x - rnorm(n = 1000, mean = 0, sd = 1)

# 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 = x, asp = 2000)
plot(x = x, asp = 10)
plot(x = x, asp = 1)
plot(x = x, asp = 1/2)
##


Cheers,

Josh

On Thu, Aug 19, 2010 at 2:13 PM, r.ookie r.oo...@live.com 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?

 __
 R-help@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/

__
R-help@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.


Re: [R] Aspect Ratio

2010-08-19 Thread David Winsemius


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


Re: [R] Aspect Ratio

2010-08-19 Thread r.ookie
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?

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


Re: [R] Aspect Ratio

2010-08-19 Thread David Winsemius


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


Re: [R] Aspect Ratio

2010-08-19 Thread r.ookie
I'm asking to get people's interpretation and also whether they've encountered 
situations where it was useful, helpful, etc.

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


Re: [R] Aspect Ratio

2010-08-19 Thread Spencer Graves
   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@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@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.


Re: [R] Aspect Ratio

2010-08-19 Thread Joshua Wiley
On Thu, Aug 19, 2010 at 2:46 PM, r.ookie r.oo...@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@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/

__
R-help@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.


Re: [R] Aspect Ratio

2010-08-19 Thread Ted Harding
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@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@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.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 19-Aug-10   Time: 23:05:49
-- XFMail --

__
R-help@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.


Re: [R] Aspect Ratio

2010-08-19 Thread r.ookie
plot(1:3) # usual way to view

plot(1:3, asp = 2) # convenient way to apply horizontal compression for 
visibility

plot(1:3, xlim = c(0, 4)) # but if you have information on what the graph looks 
like, you can manually apply the same horizontal compression

Was I going through some sort of gang initiation because I'm new, and didn't 
know it?

Phew, I'm glad it's over. Thanks for the help Spencer.

On Aug 19, 2010, at 2:50 PM, 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@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@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.


Re: [R] Aspect Ratio

2010-08-19 Thread r.ookie
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.oo...@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@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/

__
R-help@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.


Re: [R] Aspect Ratio

2010-08-19 Thread Gavin Simpson
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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@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.


Re: [R] Aspect Ratio

2010-08-19 Thread r.ookie
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@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@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.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 19-Aug-10   Time: 23:05:49
-- XFMail --

__
R-help@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.

__
R-help@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.


Re: [R] Aspect Ratio

2010-08-19 Thread r.ookie
Thanks for your example as well. Ted's example was exactly what I needed.

On Aug 19, 2010, at 3:18 PM, Gavin Simpson wrote:

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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@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.


Re: [R] Aspect Ratio

2010-08-19 Thread Spencer Graves

 The 'fortunes' package contains the following:


library(fortunes)
fortune('rtfm')

This is all documented in TFM. Those who WTFM don't want to have to WTFM 
again

on the mailing list. RTFM.
   -- Barry Rowlingson
  R-help (October 2003)


  I see two problems with this:


1.  It's difficult to RTFM if one does not know which FMTR.


2. No piece of prose in any language is ever perfectly 
clear, complete and concise to all readers.  In learning mathematics, it 
is common to spend hours on one page.  I once heard of a famous 
professor in the middle of a lecture start to say, It is intuitively 
obvious.  The he paused for 15 minutes before repeating, Yes, it is 
intuitively obvious that ... .  One of the enormous advantages of the R 
package system is that anything not obvious to a particular reader can 
be traced line by line in any number of different examples until 
sufficient enlightenment is achieved.



  Best Wishes,
  Spencer Graves


On 8/19/2010 3:38 PM, r.ookie wrote:

Thanks for your example as well. Ted's example was exactly what I needed.

On Aug 19, 2010, at 3:18 PM, Gavin Simpson wrote:

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?


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


Re: [R] Aspect Ratio

2010-08-19 Thread r.ookie
Well-stated.

On Aug 19, 2010, at 4:31 PM, Spencer Graves wrote:

The 'fortunes' package contains the following:


library(fortunes)
fortune('rtfm')

This is all documented in TFM. Those who WTFM don't want to have to WTFM again
on the mailing list. RTFM.
  -- Barry Rowlingson
 R-help (October 2003)


 I see two problems with this:


   1.  It's difficult to RTFM if one does not know which FMTR.


   2. No piece of prose in any language is ever perfectly clear, 
complete and concise to all readers.  In learning mathematics, it is common to 
spend hours on one page.  I once heard of a famous professor in the middle of a 
lecture start to say, It is intuitively obvious.  The he paused for 15 
minutes before repeating, Yes, it is intuitively obvious that ... .  One of 
the enormous advantages of the R package system is that anything not obvious to 
a particular reader can be traced line by line in any number of different 
examples until sufficient enlightenment is achieved.


 Best Wishes,
 Spencer Graves


On 8/19/2010 3:38 PM, r.ookie wrote:
 Thanks for your example as well. Ted's example was exactly what I needed.
 
 On Aug 19, 2010, at 3:18 PM, Gavin Simpson wrote:
 
 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?

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