title: How to set background color of ggplot and facet_grid in R?
body: <p>I have a rather complicated faceted boxplot in which I would like to make two groups more distinguishable, e.g. by coloring the background of the facets, but grouping 2 facet_grids would be possible, too, or adding a border around the 2 areas.</p>
  
  <p>I tried to modify the background color for certain grids in a facet_grid based on the factor of a variable:  </p>
  
  <pre><code>mtcars$type &lt;- "Small"
  mtcars$type[mtcars$cyl &gt;= 6] &lt;- "Medium"
  mtcars$type[mtcars$cyl &gt;= 8] &lt;- "Big"
  mtcars$type &lt;- factor(mtcars$type)
  
  mtcars$typeColor &lt;- "black"
  mtcars$typeColor[mtcars$cyl &gt;= 8] &lt;- "white"
  mtcars$typeColor &lt;- factor(mtcars$typeColor)
  
  p &lt;- ggplot(mtcars, aes(factor(gear), mpg, fill=factor(gear)))
  p &lt;- p + geom_boxplot()
  p &lt;- p + facet_grid(. ~ type)
  p &lt;- p + geom_rect(aes(xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, fill=factor(typeColor)))
  show(p)
  </code></pre>
  
  <p>but I can't manage to plot a geom_rect into the background properly (fill of boxplot and fill of geom_rect are disturbing each other), and don't know about other solutions, yet.</p>