Rotating x axis labels in R for barplot

David picture David · Apr 23, 2012 · Viewed 279.4k times · Source

I am trying to get the x axis labels to be rotated 45 degrees on a barplot with no luck. This is the code I have below:

barplot(((data1[,1] - average)/average) * 100,
        srt       = 45,
        adj       = 1,
        xpd       = TRUE,
        names.arg = data1[,2],
        col       = c("#3CA0D0"),
        main      = "Best Lift Time to Vertical Drop Ratios of North American Resorts",
        ylab      = "Normalized Difference",
        yaxt      = 'n',
        cex.names = 0.65,
        cex.lab   = 0.65)

Answer

Michael Z picture Michael Z · Jan 11, 2015

use optional parameter las=2 .

barplot(mytable,main="Car makes",ylab="Freqency",xlab="make",las=2)

enter image description here