0 votes
1 view
in R Programming by (7.3k points)

I have a plot where the x-axis is a factor whose labels are long. While probably not an ideal visualization, for now, I'd like to simply rotate these labels to be vertical. I've figured this part out with the code below, but as you can see, the labels aren't totally visible.

data(diamonds)

diamonds$cut <- paste("Super Dee-Duper",as.character(diamonds$cut))

q <- qplot(cut,carat,data=diamonds,geom="boxplot")

q + opts(axis.text.x=theme_text(angle=-90))

enter image description here

1 Answer

0 votes
by (25.4k points)

By default, the text is aligned at the center of the axis. To rotate axis labels to vertical, use the following code:

theme(axis.text.x = element_text(angle = 90, hjust = 1)

where angle rotates the text, and hjust controls horizontal justification.

In your case:

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+1 vote
2 answers
asked Jul 10, 2019 in R Programming by Ajinkya757 (5.3k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...