[R] split a y-axis to show data on different scales

John Kane jrkrideau at yahoo.ca
Sun Aug 13 23:31:25 CEST 2006

--- Rashmi Mathur <rashmim at sfu.ca> wrote:

> Hello,
> How do I split a y-axis to plot data on different
> scales?
> Eg:
> x <- 1:10
> y <-
> plot(x,y)
> I'd like to show these data on the same plot, but
> the way it's written, all
> contrast in the first 8 data points is lost.  Can R
> split a y-axis for me?
> Thanks,
> Rashmi
 As Hadley said: Don't. It can lead to
misinterpretations.  You are better off if you plot
two graphs.  Consider something like using
par(mfrow)and place the two graphs one above the other
on the same page. This will let you use a common
x-axis but avoids the split problem.

Quick and dirty example:

x <- c(1:10)
y <- c(1:10)
z <- c(21:30)
par(mfrow= c(2,1))

Have a look at Cleveland's book  The Elements of
Graphing Data (Revised Edition). W. S. Cleveland
(1994). Hobart Press, Summit, New Jersey for some
suggestions and the reason a split y-axis is not a
good idea.

More information about the R-help mailing list