Re: [R] Plots with Y axis split into two scales

2014-02-27 Thread John Kane
Here, here. 

John Kane
Kingston ON Canada


 -Original Message-
 From: 538...@gmail.com
 Sent: Wed, 26 Feb 2014 10:07:12 -0700
 To: j...@mail.bitwrit.com.au, achim.zeil...@r-project.org
 Subject: Re: [R] Plots with Y axis split into two scales
 
 I nominate the following for the fortunes package.
 
 
 . I still don't think it would be fair to the data, and you
 don't want those data liberation people parading around your laboratory
 with pictures of helpless data being devoured by a Babbage Difference
 Engine.
 
 
 
 --
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.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.


FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

__
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] Plots with Y axis split into two scales

2014-02-26 Thread Greg Snow
I nominate the following for the fortunes package.


 . I still don't think it would be fair to the data, and you
 don't want those data liberation people parading around your laboratory
 with pictures of helpless data being devoured by a Babbage Difference
 Engine.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.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] Plots with Y axis split into two scales

2014-02-26 Thread MacQueen, Don
Imagine you were plotting two sets, (x1, y1) and (x2, y2) on the same
plot, where x1 and x2 have the same range, but y1 and y2 need different
axis scales.

Here's an example that I think illustrates the idea. It's a long way from
being general, and if I were making it into a function in a package, I
would certainly find ways to parameterize the various y ranges.

But I think it illustrates a way to accomplish what was requested.

## some fake data
x - 1:4
y - c(1,105, 2, 130)

is.lo - y  100
x1 - x[is.lo]
y1 - y[is.lo]
x2 - x[!is.lo]
y2 - y[!is.lo]

yl1 - c(0,10)
yl2 - c(50,140)

ya1 - c(0,5)
ya2 - c(100,140)

par(mar=c(5.1, 4.1, 4.1, 4.1))

plot(range(x), yl1, type='n', yaxt='n', ylab='', xlab='X')
mtext('Low range of Y', side=2, line=2.5, adj=0.25)
points(x1,y1)
axis(2, pretty(ya1))

par(new=TRUE)## this is the key trick

## I can now add data to the existing plot,
## using any data ranges I want

plot(range(x), yl2, type='n', yaxt='n', xaxt='n', ylab='', xlab='')
points(x2,y2, col='red')
axis(4, pretty(ya2))
mtext('High range of Y', side=4, line=2.5, adj=0.75)




One can build exactly what one wants using base R graphics tools.

(And I decline to address questions of whether such a plot is a good way
to present data)


-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 2/25/14 9:18 AM, David Parkhurst parkh...@imap.iu.edu wrote:

I have a Y variable with many values less than 50, and many fewer
between 50 and 250.I'd like to plot those Y's against an X, with two
scales on the Y axis---maybe 60% of the axis height for 0-50 and the top
40% for 50-250.(I can't use log(Y) because there are many zeroes, and
that is the most desirable value.)

I think I've seen plots done that way, but is there a way to create them
in R?

Thanks for any help.


   [[alternative HTML version deleted]]

__
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] Plots with Y axis split into two scales

2014-02-25 Thread Greg Snow
One option is the gap.plot function in the plotrix package.

On Tue, Feb 25, 2014 at 10:18 AM, David Parkhurst parkh...@imap.iu.edu wrote:
 I have a Y variable with many values less than 50, and many fewer
 between 50 and 250.I'd like to plot those Y's against an X, with two
 scales on the Y axis---maybe 60% of the axis height for 0-50 and the top
 40% for 50-250.(I can't use log(Y) because there are many zeroes, and
 that is the most desirable value.)

 I think I've seen plots done that way, but is there a way to create them
 in R?

 Thanks for any help.


 [[alternative HTML version deleted]]

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



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.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] Plots with Y axis split into two scales

2014-02-25 Thread Jeff Newmiller
Please be a good netizen and post plain text on the list.

Jim can probably point you to some plotrix function that will do what you ask, 
but I would encourage you to plot the data twice rather than confusing the 
audience with nonlinear (discontinuous) scales in a single plot.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On February 25, 2014 9:18:50 AM PST, David Parkhurst parkh...@imap.iu.edu 
wrote:
I have a Y variable with many values less than 50, and many fewer 
between 50 and 250.I'd like to plot those Y's against an X, with two 
scales on the Y axis---maybe 60% of the axis height for 0-50 and the
top 
40% for 50-250.(I can't use log(Y) because there are many zeroes, and 
that is the most desirable value.)

I think I've seen plots done that way, but is there a way to create
them 
in R?

Thanks for any help.


   [[alternative HTML version deleted]]

__
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] Plots with Y axis split into two scales

2014-02-25 Thread Jim Lemon
 I have a Y variable with many values less than 50, and many fewer
 between 50 and 250.I'd like to plot those Y's against an X, with two
 scales on the Y axis---maybe 60% of the axis height for 0-50 and the top
 40% for 50-250.(I can't use log(Y) because there are many zeroes, and
 that is the most desirable value.)

Hi David,
You can't do this with gap.plot because the scale of the ordinate stays
the same over its extent. You could do it with twoord.plot, but it is
probably not a good idea. twoord.plot was written to allow the viewer to
eyeball the relationship between two variables with different metrics on
a common abcissa. What you describe above is two sections of the same plot
of one variable with two different scales on the same axis. This kind of
defeats the whole idea of representing a variable's values in some visual
metric.

Having been almost as negative as the logarithms you would need to
represent your zeros, I will offer a few suggestions. If you are worried
about crowding of large numbers of points in the lower portion of the
plot, perhaps you could use smaller symbols (e.g. plot them with text
using . with adj=c(0.5,0)) or look at the count.overplot function in
plotrix. I suppose you could use twoord.plot by breaking up the the values
into two sets and adjusting the ylim on each side so that the two sets of
values had a gap between them and then sticking in a gap style
axis.break. I still don't think it would be fair to the data, and you
don't want those data liberation people parading around your laboratory
with pictures of helpless data being devoured by a Babbage Difference
Engine.

Jim

__
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] Plots with Y axis split into two scales

2014-02-25 Thread Peter Alspach
Another suggestion - would a square-root scale work for you?

Peter Alspach

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Jim Lemon
Sent: Wednesday, 26 February 2014 3:00 p.m.
To: David Parkhurst
Cc: r-help@r-project.org
Subject: Re: [R] Plots with Y axis split into two scales

 I have a Y variable with many values less than 50, and many fewer 
 between 50 and 250.I'd like to plot those Y's against an X, with two 
 scales on the Y axis---maybe 60% of the axis height for 0-50 and the 
 top 40% for 50-250.(I can't use log(Y) because there are many zeroes, 
 and that is the most desirable value.)

Hi David,
You can't do this with gap.plot because the scale of the ordinate stays the 
same over its extent. You could do it with twoord.plot, but it is probably not 
a good idea. twoord.plot was written to allow the viewer to eyeball the 
relationship between two variables with different metrics on a common abcissa. 
What you describe above is two sections of the same plot of one variable with 
two different scales on the same axis. This kind of defeats the whole idea of 
representing a variable's values in some visual metric.

Having been almost as negative as the logarithms you would need to represent 
your zeros, I will offer a few suggestions. If you are worried about crowding 
of large numbers of points in the lower portion of the plot, perhaps you could 
use smaller symbols (e.g. plot them with text using . with adj=c(0.5,0)) or 
look at the count.overplot function in plotrix. I suppose you could use 
twoord.plot by breaking up the the values into two sets and adjusting the ylim 
on each side so that the two sets of values had a gap between them and then 
sticking in a gap style axis.break. I still don't think it would be fair to 
the data, and you don't want those data liberation people parading around your 
laboratory with pictures of helpless data being devoured by a Babbage 
Difference Engine.

Jim

__
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.
The contents of this e-mail are confidential and may be ...{{dropped:14}}

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