[R] How to add break in axis for grouped barplot?

Jim Lemon jim at bitwrit.com.au
Tue May 27 14:11:29 CEST 2014


On Tue, 27 May 2014 11:36:21 AM Wei Qin wrote:
> ...
> #Then my questions is how to make a broken y axis in grouped 
barplot
> figures?
> 
> # In another words, how to combine the function of barplot and 
gap.barplot?
> 
Hi Wei,
The gap.barplot function doesn't do grouped bars (yet). You can probably 
get what you want with this:

newdata<-data
newdata[newdata>200]<-newdata[newdata>200]-140
barpos<-barplot(newdata,names.arg=colnames(newdata),
 ylim=c(0,250),beside=TRUE,col=c("darkblue","red"),axes=FALSE)
axis(2,at=c(0,50,100,150,200,235),
 labels=c(0,50,100,150,200,375))
box()
axis.break(2,210,style="gap")

Jim



More information about the R-help mailing list