Re: [R] Putting 2 breaks on Y axis

2007-04-12 Thread Marc Schwartz
On Thu, 2007-04-12 at 13:41 -0500, Inman, Brant A. M.D. wrote:
 R plotting experts:
 
 I have a bivariate dataset composed of 300 (x,y) continuous datapoints.
 297 of these points are located within the y range of [0,10], while 2
 are located at 20 and one at 55.  No coding errors, real outliers.
 
 When plotting these data with a scatterplot, I obviously have a problem.
 If I plot the full dataset with ylim = c(0,55), then I cannot see the
 structure in the data in the [0, 10] range.  If I truncate the y axis
 with ylim = c(0,10), then I cannot see the 3 outliers.  If I break the y
 axis from 10 to 20 (using plotrix functions), I still do not see the
 data optimally because of the white space from y=20 to y=55.
 
 What I would like to do is break the y axis at 2 points, roughly 10-20
 and 20-55. Is there a function that can break an axis in 2 places?
 
 Thanks in advance for any suggestions.
 
 Brant


Brant, 

I am not a particular fan of broken axes (though others will disagree),
much less two breaks.

Presuming that your data might look something like this:

http://www.itl.nist.gov/div898/handbook/eda/section3/scattera.htm

A couple of thoughts:

1. Not being sure if your data range above actually includes 0, you may
want to consider a log scaled axis, if not.

2. I might be tempted to use two plots:

  A. A first a plot of the entire data set, showing the 3 outliers

  B. A second plot of the 297 pairs with axes constrained to the
 appropriate ranges to enable better visualization of the data
 structure.

If number 2 is more appropriate, you could also use par(mfcol) to set
up side by side plots. See ?par.

HTH,

Marc Schwartz

__
[EMAIL PROTECTED] 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] Putting 2 breaks on Y axis

2007-04-12 Thread Stephen Weigand
On 4/12/07, Marc Schwartz [EMAIL PROTECTED] wrote:
 On Thu, 2007-04-12 at 13:41 -0500, Inman, Brant A. M.D. wrote:
  R plotting experts:
 
  I have a bivariate dataset composed of 300 (x,y) continuous datapoints.
  297 of these points are located within the y range of [0,10], while 2
  are located at 20 and one at 55.  No coding errors, real outliers.
 
  When plotting these data with a scatterplot, I obviously have a problem.
  If I plot the full dataset with ylim = c(0,55), then I cannot see the
  structure in the data in the [0, 10] range.  If I truncate the y axis
  with ylim = c(0,10), then I cannot see the 3 outliers.  If I break the y
  axis from 10 to 20 (using plotrix functions), I still do not see the
  data optimally because of the white space from y=20 to y=55.
 
  What I would like to do is break the y axis at 2 points, roughly 10-20
  and 20-55. Is there a function that can break an axis in 2 places?
 
  Thanks in advance for any suggestions.
 
  Brant


 Brant,

 I am not a particular fan of broken axes (though others will disagree),
 much less two breaks.

 Presuming that your data might look something like this:

 http://www.itl.nist.gov/div898/handbook/eda/section3/scattera.htm

 A couple of thoughts:

 1. Not being sure if your data range above actually includes 0, you may
 want to consider a log scaled axis, if not.

 2. I might be tempted to use two plots:

   A. A first a plot of the entire data set, showing the 3 outliers

   B. A second plot of the 297 pairs with axes constrained to the
  appropriate ranges to enable better visualization of the data
  structure.

 If number 2 is more appropriate, you could also use par(mfcol) to set
 up side by side plots. See ?par.

 HTH,

 Marc Schwartz


I was thinking plot the data without the outliers and include a
smaller inscribed plot in a corner showing all the data (the global
view). But I couldn't figure out how to do this.

(I think legend() works very hard to do this type of thing.)

Stephen

__
[EMAIL PROTECTED] 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] Putting 2 breaks on Y axis

2007-04-12 Thread Greg Snow
Try something like this (modify to how you like it):

x - runif(100)
y - rnorm(100, 5, 2)
 
y[1:3] - c(19, 21, 50)

layout(matrix( 3:1, ncol=1 ), heights=c(2,3,4))

par(mar=c(5,4,0,2)+0.1)
plot(x,y, ylim=c(0,10), ylab='')

par(mar=c(0.5,4,0,2)+0.1)
plot(x,y, ylim=c(18,22), xlab='', xaxt='n' )
axis(1, labels=FALSE)

par(mar=c(0.5,4,4,2)+0.1) 
plot(x,y, ylim=c(49,51),xlab='', main='my title', xaxt='n', ylab='' )
axis(1, labels=FALSE)


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Inman, 
 Brant A. M.D.
 Sent: Thursday, April 12, 2007 12:41 PM
 To: [EMAIL PROTECTED]
 Subject: [R] Putting 2 breaks on Y axis
 
 
 R plotting experts:
 
 I have a bivariate dataset composed of 300 (x,y) continuous 
 datapoints.
 297 of these points are located within the y range of [0,10], 
 while 2 are located at 20 and one at 55.  No coding errors, 
 real outliers.
 
 When plotting these data with a scatterplot, I obviously have 
 a problem.
 If I plot the full dataset with ylim = c(0,55), then I cannot 
 see the structure in the data in the [0, 10] range.  If I 
 truncate the y axis with ylim = c(0,10), then I cannot see 
 the 3 outliers.  If I break the y axis from 10 to 20 (using 
 plotrix functions), I still do not see the data optimally 
 because of the white space from y=20 to y=55.
 
 What I would like to do is break the y axis at 2 points, 
 roughly 10-20 and 20-55. Is there a function that can break 
 an axis in 2 places?
 
 Thanks in advance for any suggestions.
 
 Brant
 
 __
 [EMAIL PROTECTED] 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.


__
[EMAIL PROTECTED] 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] Putting 2 breaks on Y axis

2007-04-12 Thread Jim Lemon
Inman, Brant A. M.D. wrote:
 R plotting experts:
 
 I have a bivariate dataset composed of 300 (x,y) continuous datapoints.
 297 of these points are located within the y range of [0,10], while 2
 are located at 20 and one at 55.  No coding errors, real outliers.
 
 When plotting these data with a scatterplot, I obviously have a problem.
 If I plot the full dataset with ylim = c(0,55), then I cannot see the
 structure in the data in the [0, 10] range.  If I truncate the y axis
 with ylim = c(0,10), then I cannot see the 3 outliers.  If I break the y
 axis from 10 to 20 (using plotrix functions), I still do not see the
 data optimally because of the white space from y=20 to y=55.
 
 What I would like to do is break the y axis at 2 points, roughly 10-20
 and 20-55. Is there a function that can break an axis in 2 places?
 
Hi Brant,

gap.plot in the plotrix package can do one break, and it is possible to 
do two, as gap.boxplot does. It wouldn't be too difficult to recode 
gap.plot to get more than one break. I'll see what I can do today.

Jim

__
[EMAIL PROTECTED] 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] Putting 2 breaks on Y axis

2007-04-12 Thread Greg Snow
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Stephen Weigand
 Sent: Thursday, April 12, 2007 2:32 PM
 To: Inman, Brant A. M.D.
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] Putting 2 breaks on Y axis
 

[snip]

 
 I was thinking plot the data without the outliers and include 
 a smaller inscribed plot in a corner showing all the data 
 (the global view). But I couldn't figure out how to do this.
 
 (I think legend() works very hard to do this type of thing.)

This is fairly easy to do with the subplot function in the TeachingDemos
package:


 
 Stephen
 




-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111

__
[EMAIL PROTECTED] 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.