Barplot arguments

Asked

Viewed 220 times

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 place them vertically use them=2, but I want them to be inclined (an angle of 45°). How do I do?

This is 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)

1 answer

5

To rotate you will need to use the command text to create the X axis. In function text there is the argument srt to specify the rotation degrees. Also include the argument xaxt = "n" in charge of the barplot 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)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.