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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Putting value labels inside the bars of a bar plot
2 messages · Tom Arnold, Paul Murrell
Hi
Tom Arnold wrote:
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?
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
Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x5392 paul at stat.auckland.ac.nz -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._