adelriosantiago
adelriosantiago

Reputation: 8124

Add a position offset to x axes titles in R's ggplot

In R. I currently have this ggplot:

enter image description here

And I am looking to get the titles right in the center of the square, like this:

enter image description here

I took a look at ?element_text but there is no position/offset setting. How can I move offset x-axes in a ggplot?

Upvotes: 1

Views: 348

Answers (1)

Duck
Duck

Reputation: 39595

Maybe try with the theme() I have added:

library(ggplot2)
#Code
ggplot(iris,aes(x=Species,y=Sepal.Length))+
  geom_boxplot(aes(fill=Species))+
  theme(axis.text.x = element_text(angle = 90,vjust = 0.5))

Output:

enter image description here

Upvotes: 2

Related Questions