[R] Subject: Re: how to include bar values in a barplot?

Jim Lemon jim at bitwrit.com.au
Fri Aug 10 11:42:43 CEST 2007


Gabor Grothendieck wrote:
> You could put the numbers inside the bars in which
> case it would not add to the height of the bar:
> 
> x <- 1:5
> names(x) <- letters[1:5]
> bp <- barplot(x)
> text(bp, x - .02 * diff(par("usr")[3:4]), x)
> 
Indeed, the boxed.labels function makes this pretty easy.
boxed.labels(bp,x-0.2*diff(par("usr")[3:4]),x)

gives you the labels in a little white rectangle so that none are invisible.

I also greatly enjoyed Ted's rebuttal of the "Bar charts are evil and 
must be banned" argument. If bar charts are appropriate for the 
audience, give 'em bar charts. One great way to turn off your customers 
is to tell them what they can and can't do with your product.

Jim



More information about the R-help mailing list