If you want to rotate the x-axis labels with an angle equal to or less than 90, try the following approach:
It uses the argument barplot space=1 so that the column width is equal to the spacing of the column spacing.
In this way, it was possible to adapt the code presented at frequently asked frequencies , which was determined by @BenBarnes under Tyler Rinker's answer.
par(mar = c(7, 4, 2, 2) + 0.2) #add room for the rotated labels #use mtcars dataset to produce a barplot with qsec colum information mtcars = mtcars[with(mtcars, order(-qsec)), ] #order mtcars data set by column "qsec" (source: http://stackoverflow.com/questions/1296646/how-to-sort-a-dataframe-by-columns-in-r) end_point = 0.5 + nrow(mtcars) + nrow(mtcars)-1 #this is the line which does the trick (together with barplot "space = 1" parameter) barplot(mtcars$qsec, col="grey50", main="", ylab="mtcars - qsec", ylim=c(0,5+max(mtcars$qsec)), xlab = "", space=1) #rotate 60 degrees, srt=60 text(seq(1.5,end_point,by=2), par("usr")[3]-0.25, srt = 60, adj= 1, xpd = TRUE, labels = paste(rownames(mtcars)), cex=0.65)

Andre Silva Feb 24 '14 at 3:54 a.m. 2014-02-24 03:54
source share