# Re: [R] How to break an axis?

From: Jim Lemon <bitwrit_at_ozemail.com.au>
Date: Wed 25 May 2005 - 05:06:41 EST

Bo Peng wrote:
> Dear list,
>
> I need to plot four almost horizontal lines with y-values around
> 1,3,4, 400. If I plot them directly, the first three lines will be
> indiscernible so I am thinking of breaking y-axis into two parts, one
> with range (0,5), another (395,400). Is there an easy way to do this?
>
> I can think of two ways:
> 1. use two plots and draw axes manually. The plot margins, are however
> 2. use one plot, adjust y-values of the lines and draw y-axis
> manually. But, how would I break y-axis and add separation symbols
> *on* yaxis? (By separation symbol, I mean something like
> ------//------
>
Hi Bo,

```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="")

Jim

R-help@stat.math.ethz.ch mailing list