Skip to content

Putting value labels inside the bars of a bar plot

2 messages · Tom Arnold, Paul Murrell

#
I'd like to label a bar plot with the actual value of each bar, inside the
bar. I see that there are ways to plot arbitrary text, so I could do it
'manually', but this seems common enough that there's probably a simple
solution. I don't see it in the high-level documentation for barplot, and
haven't found it anywhere yet. How might this be done?

Thanks,
Tom

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Hi
Tom Arnold wrote:
The trick is to know that barplot returns the x-location of the
midpoints of the bars.  Here's a simple example:

	x <- sample(seq(15, 30, 5))
	midpoints <- barplot(x)
	text(midpoints, 3, labels=x)

Paul