2

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:

M--
  • 25,431
  • 8
  • 61
  • 93
user553480
  • 321
  • 1
  • 8
  • 1
    Please [edit as stated here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) Is there any reason you want to use `facet_*` to achieve this? – NelsonGon May 15 '20 at 16:30
  • I am not sure if `horizontal` is clear !!! But for *cut off*, a solution would be to use `stringr::str_wrap` for text wrapping. – nikn8 May 15 '20 at 16:37
  • You should provide a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). It should be [minimal, but complete and verifiable example](https://stackoverflow.com/help/minimal-reproducible-example). Your question should be clear and specific. I posted an answer. Hopefully it works for your dataset; but if you post a **minimal** and **reproducible** example of your data (not all of it, remember), then we can be sure that we've been helpful. – M-- May 15 '20 at 16:48
  • 1
    check out https://stackoverflow.com/questions/29357612/plot-labels-at-ends-of-lines for another visualisation option – tjebo May 15 '20 at 16:54

1 Answers1

5

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")

M--
  • 25,431
  • 8
  • 61
  • 93