Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make facet labels horizontal in ggplot2

I want the names on the right hand side labels of the facet plot to be horizontally so they are not cut off. For example, so it reads North England, East Midlands, etc.

Image here:

like image 336
user553480 Avatar asked Apr 08 '26 17:04

user553480


1 Answers

You can use strip.text.y = element_text(angle = 0) to rotate the facet strips on the right. I am using iris dataset to make a reproducible example.

library(ggplot2)

    ggplot() +
      geom_line(data= iris, aes(x = Sepal.Length, y = Petal.Width, 
                                colour = Species), stat = "identity") +
      facet_wrap(Species ~ ., strip.position = "right", ncol = 1, scales = "free_y") +
      theme_bw() +
      theme(strip.text.y = element_text(angle = 0),
            legend.position = "none")

like image 92
M-- Avatar answered Apr 11 '26 06:04

M--