[R] Barplots

Suzanne E. Blatt SuzieBlatt at netscape.net
Fri Nov 7 21:16:13 CET 2003


Thanks for the suggestion below.  I did one of my figures and it worked perfectly.  I tried it on my second figure and got double-labelling on the first bar.  I used the same code to create both figures, and the same code to label.  I've attached the code for one of the plots (there were 3/figure) if anyone has a chance to figure out why.


Philipp Pagel <p.pagel at gsf.de> wrote:

>    Hi!
>On Fri, Nov 07, 2003 at 10:46:27AM -0500, Suzanne E. Blatt wrote:
>> Can anyone tell me how to label individual bars on a barplot?  I want
>> to put an "*" or letter ABOVE the bar to denote statistical
>> significance.  Is this possible and how?
>You can use text() to put arbitrary strings in your plot. So you only
>need to add some offset to your y-values and work out the x-positions:
>y <- c(10,12,15,8)
>lab <- c('*','**','***','*')
>barplot(y, ylim=c(0,20), space=0.5)
>x <- (0:3*0.5)+1:4 
>text(x, y+1, lab, adj=0.5)
>    Philipp
>Dr. Philipp Pagel                                Tel.  +49-89-3187-3675
>Institute for Bioinformatics / MIPS              Fax.  +49-89-3187-3585
>GSF - National Research Center for Environment and Health
>Ingolstaedter Landstrasse 1
>85764 Neuherberg, Germany
>R-help at stat.math.ethz.ch mailing list

McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!

Get AOL Instant Messenger 5.1 free of charge.  Download Now!

More information about the R-help mailing list