Re: [R] How to break an axis?

From: Bo Peng <>
Date: Wed 25 May 2005 - 00:38:54 EST

> Tom Mulholland has already pointed out that the plotrix package has an
> axis.break() function that will draw the break symbol. Your problem is a
> combination of plotting two disparate sets of data and getting the
> y-axis right. The following is one way to do it, just be careful that
> the ylim= and labels= arguments match up.
> y1<-1+rnorm(10)/5
> y2<-3+rnorm(10)/5
> y3<-4+rnorm(10)/5
> y4<-397+rnorm(10)/5
> library(plotrix)
> plot(y1,ylim=c(0,10),axes=FALSE,main="Big range plot",ylab="Y values")
> points(y2)
> points(y3)
> box()
> axis(2,at=c(1,2,3,4,6,7,8,9),labels=c("1","2","3","4","396","397","398","399"))
> axis.break(2,5)
> par(new=TRUE)
> plot(y4,ylim=c(390,400),axes=FALSE,main="",ylab="",xlab="")

Thank you very much for the real code. I did almost exactly the same thing. I did not know the new=TRUE option so I used lines(y4-offset, ...). Anyway, the results are the same.

The left-right-axes solution is also very interesting. It is actually better if the ranges of lines differ significantly.

Thank you again for the help.
Bo mailing list PLEASE do read the posting guide! Received on Wed May 25 00:53:25 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:01 EST