The return value of barplot contains the locations of the bars that it just drew. Use that instead of 1:8 when you draw the text:
> barCenters <- barplot(X2sum) > text(barCenters, par("usr")[3] - 0.5, srt = 45, adj = 1, labels =X2.labels, > xpd = TRUE) Look at help(barplot) for details. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of jon waterhouse > Sent: Friday, March 02, 2012 11:52 AM > To: r-help@r-project.org > Subject: [R] Spacing of text does not match spacing of bars in barplot > > I have a very standard barplot. My labels are too long to be printed > horizontally under each bar, so I am using text to put the labels on a 45 > degree slant. > > However, the labels are spaced more narrowly than the bars, so on an 8 > vertical bar plot, the end of the eighth label is lined up with the seventh > bar. > > Preferably I don't want to do every text label separately (I'm having this > problem on all the graphs where I'm using text() > > Using Windows and version 2.14.1 > > X2sum <- c(42.6, 3.6, 1.8, 3.9, 12.1, 14.3, 14.6 ,28.4) > X2.labels <- c("No earnings", "Less than $5000/year", "$5K to $10K" , "$10K > to $15K" , "$ 15K to $20K" , "$20K to $25K" , "$25K to $30K" > , "Over $30K" ) > > barplot(X2sum) > text(1:8, par("usr")[3] - 0.5, srt = 45, adj = 1, labels =X2.labels, xpd = > TRUE) > > Thanks, > > Jon > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Spacing-of-text-does-not-match-spacing-of- > bars-in-barplot-tp4439635p4439635.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.