Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (7.3k points)
edited by

I'm wondering how I can manipulate the size of strip text in facetted plots. My question is similar to a question on plot titles, but I'm specifically concerned with manipulating not the plot title but the text that appears in facet titles (strip_h).

As an example, consider the mpg dataset.

    library(ggplot2) 

    qplot(hwy, cty, data = mpg) + facet_grid( . ~ manufacturer)

The resulting output produces some facet titles that don't fit in the strip.

I'm thinking there must be a way to use the grid to deal with the strip text. But I'm still a novice and wasn't sure from the grid appendix in Hadley's book how, precisely, to do it. Also, I was afraid if I did it wrong it would break my washing machine since I believe all technology is connected through The Force :-(

Many thanks in advance.

1 Answer

0 votes
by
edited by

To change the text of facet strips, you can use the following:

library(ggplot2)

qplot(hwy, cty, data = mpg) + 

  facet_grid(. ~ manufacturer) + 

  theme(strip.text.x = element_text(size = 10, colour = "black", angle = 90))

Output:

image

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...