title: Draw multiple squares with ggplot
body: <p>I am trying to change to 'background' color of a ggplot. What I want to achieve is the plot shown below. I've already tried it with <strong>geom_ribbon</strong> but than I can only define ymin and ymax. This allows me to only create two squares.</p>
  <p>The code I use so far:</p>
  <pre><code>df &lt;- data.frame(x = rnorm(10), y = rnorm(10))
  
  ggplot(df) +
   geom_point(aes(x, y)) +
   geom_ribbon(aes(x = x, ymin = min(y), ymax = 0), fill = &quot;red&quot;, alpha = .5) +
   geom_ribbon(aes(x = x, ymin = min(0), ymax = max(y)), fill = &quot;blue&quot;, alpha = .5)
  </code></pre>
  <p>And this is the result I want to get:</p>
  <p><a href="https://i.stack.imgur.com/oQ6B7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oQ6B7.png" alt="ggplot example" /></a></p>
  
  <p>Thanks for your time.</p>