Are you trying to say that you don't really like barplots????? At least the OP did not ask for error bars as well. :)
--- On Fri, 9/10/10, Dennis Murphy <djmu...@gmail.com> wrote: > From: Dennis Murphy <djmu...@gmail.com> > Subject: Re: [R] adding labels above bars in a barplot > To: "Antonio Olinto" <aolint...@bignet.com.br> > Cc: "R-help" <r-h...@stat.math.ethz.ch> > Received: Friday, September 10, 2010, 2:31 PM > Hi: > > To add to Greg's sound advice, if you want to put the > numbers on top of the > bars, why bother with the numerical scale? The entire point > of a scale is to > provide a reference for comparing different (sets of) > values. > > \begin{rant} > And when I see things like this: > > dat.bar > > VAR1 > > Category 01 17.5 > > Category 02 15.2 > > Category 03 10.3 > > Category 04 8.4 > > Category 05 20.3 > > I get doubly annoyed, because it is yet another attempt to > use a bar chart > to plot quantitative values by factor level. As I mentioned > in a private > response today, one of the problems with a bar chart is > that it forces the > numerical scale to have origin zero, and this is often > neither necessary nor > desirable. A simple line plot that connects the > quantitative values between > categories is sufficient, and takes *far* less ink to > produce. The purpose > of a statistical graphic is to convey information in a > simple, clean, > concise fashion - it is not meant to be a rococo art form. > If you intend to > write a function to automate a graphic, please think > carefully about what is > meant to be conveyed and the *visually* simplest means by > which to convey > it. > \end{rant} > > The purpose of a bar chart is to visualize a (joint) > discrete distribution. > There are better ways to plot quantitative variables by > group; in addition > to the line plot mentioned above, the Cleveland dot chart > can be very > effective with many groups or multiple grouping factors. > With two factors > and a quantitative response, another option is the > interaction plot. > > If this weren't the third such example/request I've seen > today, I probably > wouldn't be so apoplectic... > > Dennis > > On Fri, Sep 10, 2010 at 10:44 AM, Greg Snow <greg.s...@imail.org> > wrote: > > > See this message and the replies to it (and the > replies to the replies, > > etc.): > > > > http://tolstoy.newcastle.edu.au/R/e2/help/07/08/22858.html > > > > In there is a discussion of why you don't really want > to do that along with > > better alternatives and examples of the improved > plots. > > > > -- > > Gregory (Greg) L. Snow Ph.D. > > Statistical Data Center > > Intermountain Healthcare > > greg.s...@imail.org > > 801.408.8111 > > > > > > > -----Original Message----- > > > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r- > > > project.org] On Behalf Of Antonio Olinto > > > Sent: Friday, September 10, 2010 8:59 AM > > > To: R-help > > > Subject: [R] adding labels above bars in a > barplot > > > > > > Hello, > > > > > > I want to make a general routine to draw barplots > with numbers plotted > > > above each bar. See the example below. > > > > > > I could not place the numbers on the middle of > each bar because I > > > could not calculate the right position of each > x-axis tick. axTicks(1) > > > indicated a unitary step, but it does not seem > work. > > > > > > I appreciate any help or suggestions. > > > > > > Best regards, > > > > > > Antonio Olinto > > > > > > ====================== > > > > > > CAT VAR1 VAR2 > > > Category 01 17.5 9 > > > Category 02 15.2 > 20 > > > Category 03 10.3 > 500 > > > Category 04 8.4 > 150 > > > Category 05 20.3 > 5000 > > > > > > # Coping data from a spreadsheet > > > > > > dat.data <- read.delim("clipboard",header=T) > > > > > > summary(dat.data) > > > > CAT VAR1 > VAR2 > > > Category > 01:1 Min. : > 8.40 Min. : 9 > > > Category > 02:1 1st Qu.:10.30 1st > Qu.: 20 > > > Category > 03:1 Median :15.20 Median > : 150 > > > Category > 04:1 Mean :14.34 Mean :1136 > > > Category > 05:1 3rd Qu.:17.50 3rd > Qu.: 500 > > > > > Max. :20.30 Max. :5000 > > > > > > dat.bar <- data.frame(dat.data[,c(2)]) > > > row.names(dat.bar)<-dat.data[,1] > > > names(dat.bar)<-c("VAR1") > > > dat.bar > > > > VAR1 > > > Category 01 17.5 > > > Category 02 15.2 > > > Category 03 10.3 > > > Category 04 8.4 > > > Category 05 20.3 > > > > > > par(mar=c(12,6,3,2),cex.axis=1.2,cex.lab=1.4) > > > > barplot(t(as.matrix(dat.bar)),ylim=c(0,max(dat.data[,2]*1.1)),las=2,yla > > > b="Y > > > label text",col="orange") > > > box() > > > > > > up <- max(dat.data$VAR1)*0.1 > > > > > > for (i in c(0:nrow(dat.data))) { > > > > legend(0.25+i,dat.bar[1+i,1]+up,dat.data[i+1,3],col="blue",bty="n") > > > } > > > > > > > > > > ---------------------------------------------------------------- > > > Webmail - iBCMG Internet > > > http://www.ibcmg.com.br > > > > > > ______________________________________________ > > > R-help@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. > > > > ______________________________________________ > > R-help@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. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.