[R] Labeling a range of bars in barplot?

From: Dan Bolser <dmb_at_mrc-dunn.cam.ac.uk>
Date: Tue 13 Dec 2005 - 21:53:13 EST

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

barplot(sort(x,decreasing=T))

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

y

plot(diff(y))

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 covers.

Thanks for any help with the above!

Cheers,
Dan.



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 Received on Tue Dec 13 22:25:58 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:35 EST