[R] Labeling a range of bars in barplot?

Dan Bolser dmb at mrc-dunn.cam.ac.uk
Tue Dec 13 11:53:13 CET 2005

Hi, I am plotting a distribution of (ordered) values as a barplot. I 
would like to label groups of bars together to highlight aspects of the 
distribution. The label for the group should be the range of values in 
those bars.

As this is hard to describe, here is an example;

x <- rlnorm(50)*2


y <- quantile(x, seq(0, 1, 0.2))



That last plot is to highlight that I want to label lots of the small 
columns together, and have a few more labels for the bigger columns 
(more densely labeled). I guess I will have to turn out my own labels 
using low level plotting functions, but I am stumped as to how to 
perform the calculation for label placement.

I imagine drawing several line segments, one for each group of bars to 
be labeled together, and putting the range under each line segment as 
the label. Each line segment will sit under the group of bars that it 

Thanks for any help with the above!


More information about the R-help mailing list