Hello, 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? Thanks, Suzanne __________________________________________________________________ McAfee VirusScan Online from the Netscape Network. Comprehensive protection for your entire computer. Get your free trial today! http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397 Get AOL Instant Messenger 5.1 free of charge. Download Now!
On Fri, 2003-11-07 at 09:46, Suzanne E. Blatt wrote:> Hello, > 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? > > Thanks, > SuzanneYou might want to take a look at the most recent issue of R News, which has an article on R's base graphics, that contains an example of an annotated barplot(). There is also a graphic of the output. http://cran.r-project.org/doc/Rnews/Rnews_2003-2.pdf HINT: barplot() returns the bar midpoints (ie. mp <- barplot(....)) HTH, Marc Schwartz
Suzanne E. Blatt wrote:> Hello, > 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? > > Thanks, > SuzanneExamples on how to label bars in that way can be found on the help page ?barplot (well, not above but within the var, which can be adapted), and in the R Help Desk article by Marc Schwartz in the recent issue of R News, available at: http://cran.r-project.org/doc/Rnews/ Uwe Ligges
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) cu 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
Hello, 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. Thanks, Suzanne 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) > >cu > 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 >https://www.stat.math.ethz.ch/mailman/listinfo/r-help >__________________________________________________________________ McAfee VirusScan Online from the Netscape Network. Comprehensive protection for your entire computer. Get your free trial today! http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397 Get AOL Instant Messenger 5.1 free of charge. Download Now!
On Fri, Nov 07, 2003 at 03:16:13PM -0500, Suzanne E. Blatt wrote:> 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.Well, maybe you should use the x values returned by barplot (your variable blocks) instead of computing x-positions yourself as I originally suggested. cu 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