[R] Aligning Diagonally Oriented Labels Under Bar Chart

Jason Rupert jasonkrupert at yahoo.com
Wed Dec 2 00:16:26 CET 2009


I searched the forms (i.e., R Search) and come up with the following suggested link:
 http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f

I tried to implement what I believe was being implied by that URL and came up with the below:

barplot(WorldPhones[1,], 
        ylim=c(0, 50000),
        axes=FALSE, ann=FALSE, 
        col=terrain.colors(length(WorldPhones[1,])), 
        xaxt = "n",  xlab = "")

text(1:dim(WorldPhones)[1], par("usr")[3] - 0.1, srt = 45, adj = 1,
     labels = as.character(colnames(WorldPhones)), xpd = TRUE)

box()


Unfortunately the labels are not aligned with the appropriate bars.  I believe I am missing something small in order to have the text properly aligned underneath the appropriate bars.   

Are there any suggestions for correcting this mis-alignment?  

Thank you again for any additional feedback, links, hints or insights.  







More information about the R-help mailing list