[R] Plots with Y axis split into two scales

Jim Lemon jim at mail.bitwrit.com.au
Wed Feb 26 03:00:17 CET 2014


> 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




More information about the R-help mailing list