[R] Labeling a range of bars in barplot?
Hans Gardfjell
hans.gardfjell at emg.umu.se
Tue Dec 13 12:09:49 CET 2005
Is this what you want...
op<-par(xpd=TRUE)
segments(0,-1,20,-1,col=2)
text(10,-1,"Interval",pos=1)
Cheers,
Hans Gardfjell
Dept. of Ecology and Environmental science
Umeå University, Sweden
Dan Bolser wrote:
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.
More information about the R-help
mailing list