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

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Mon 14 Aug 2006 - 07:31:25 EST

• Rashmi Mathur <rashmim@sfu.ca> wrote:

> Hello,
>
> How do I split a y-axis to plot data on different
> scales?
>
> Eg:
>
> x <- 1:10
> y <-
>
c(-0.01,0.79,0.74,0.55,-0.67,0.32,-0.47,-0.05,723,759)
> 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
>
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))
plot(x,y)
plot(x,z)

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.

R-help@stat.math.ethz.ch 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. Received on Mon Aug 14 07:34:48 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 14 Aug 2006 - 08:18:34 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.