I want to label each bar on the top of bars when using barplot. anyone know how to do this? thanks
?text tmp <- c(34,22,77) tmp.labels <- c("cat", "dog", "sheep") tmp2 <- barplot(tmp, ylim=c(0, max(tmp)+10)) text(1:3, tmp+2 , labels=tmp.labels) --- Aimin Yan <aiminy at iastate.edu> wrote:> I want to label each bar on the top of bars when > using barplot. > > anyone know how to do this? > > thanks > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. >
There was a discussion on this a while back, see: http://tolstoy.newcastle.edu.au/R/e2/help/07/08/22858.html There is some good discussion there on why you may not want to do this (adding the numbers at the tops of bars tends to distort the visual comparison of heights, among other things). If you follow the thread for a while and think about what you really want to do, there are some examples of alternative ways to accomplish what you probably really want to do. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Aimin Yan > Sent: Thursday, March 13, 2008 11:10 AM > To: r-help at r-project.org > Subject: [R] label each bar by value > > I want to label each bar on the top of bars when using barplot. > > anyone know how to do this? > > thanks > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >