tags:

views:

320

answers:

1

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 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.

+3  A: 

You can modify strip.text.x (or strip.text.y) using theme_text(), for instance

qplot(hwy, cty, data = mpg) + 
      facet_grid(. ~ manufacturer) + 
      opts(strip.text.x = theme_text(size = 8, colour = "red", angle = 90))
rcs
+1 Very nice. Is there a way to improve also the x axis annotation?
gd047
Thanks rcs. I'm with gd047, and perhaps that should be a separate question? What you're noticing is the crowding of major x-values, I think.There should be a way to set the values of the major x-axis and y-axis tick marks manually, but I can't remember what it is :-(
briandk
@gd047: `axis.text.x=theme_text(...)`
rcs