[R] Spacing of text does not match spacing of bars in barplot

jon waterhouse jonwaterhouse at gov.nl.ca
Fri Mar 2 20:52:00 CET 2012


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.



More information about the R-help mailing list