[R] add information above bars of a barplot()

Rubén Roa rroa at azti.es
Mon Mar 22 16:53:33 CET 2010


-----Mensaje original-----
De: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] En nombre de Martin Batholdy
Enviado el: lunes, 22 de marzo de 2010 15:53
Para: r help
Asunto: [R] add information above bars of a barplot()

hi,


I have a barplot with six clusters of four bars each.
Now I would like to add the exact value of each bar as a number above the bar.

I hoped to get some tips here.
I could simply add text at the different positions, but I don't understand how the margins on the x-axis are calculated (how can I get / calculate the x-ticks of a barplot?).

Also I would like to code this flexible enough so that it still works when I have more bars in each cluster.



thanks for any suggestions!



--------

If you are barplotting x

barplot(x)
text(x=barplot(x),y=x,label=format(x),po=3)

should get you closer to what you want.

HTH

Rubén



More information about the R-help mailing list