Arguments bar plot

Question:

I made a graph with the barplot function, and I need to change the angle of the text on the X axis, because the words are long. I know to place them vertically use las=2, but I want them to be slanted (a 45° angle). How do I do?

This was the script I used:

barplot(prop.sentenca [ ,1], beside = T, 
main = "Proporção de aplicação do imperativo com morfologia de indicativo \n por Sentença em Feira de Santana-BA", names.arg = c("correr","sair", "viajar", "cozinhar", "comprar", "arrumar"),
ylim = c(0,90), ylab = "Proporção do imperativo com morfologia de indicativo", 
xlab = "Sentença", col = c("deepskyblue"),las=2)

Answer:

To rotate you will have to use the text command to create the X axis. In the text function there is an argument srt to indicate the degrees of rotation. Also include the xaxt = "n" argument in the barplot command so as not to create the same (X-axis) twice.

Below is a code I found with a quick Google search.

labels <- month.name[1:12]
mp <- barplot(1:12, xaxt = "n", axisnames = FALSE)
text(mp, par("usr")[3], labels = labels, srt = 45, adj = c(1.1,1.1), xpd = TRUE, cex=.9)
Scroll to Top