Arguments barplot

5

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 that to put them vertically use las = 2, but I want them to be inclined (an angle of 45 °). 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)
    
asked by anonymous 13.09.2017 / 17:13

1 answer

5

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

Here is a code that I found with a quick search on Google.

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)
    
13.09.2017 / 17:52