NERD
NERD

Reputation: 19

How to rotate category title with facet_wrap?

look at my code:

library(ggplot2)

ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  facet_wrap(vars(class))

enter image description here

How to rotate the title of each category (2seater, compact etc), to place them on the right and horizontal?

Upvotes: 0

Views: 78

Answers (1)

stefan
stefan

Reputation: 125697

You could place the strip text on the right via the strip.position argument of facet_wrap and make them horizontal via the theme option strip.text.y:

library(ggplot2)

ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  facet_wrap(vars(class), strip.position = "right") +
  theme(strip.text.y = element_text(angle = 0))

Upvotes: 1

Related Questions