title: Shade region between two lines with ggplot
body: <p>I produce the folowing two lines with ggplot and would like to shade a specific region between the two lines i.e. where y=x² is greater than y=2x, where 2 &lt;= x &lt;= 3.</p>
  
  <pre><code># create data #
  
  x&lt;-as.data.frame(c(1,2,3,4))
  colnames(x)&lt;-"x"
  x$twox&lt;-2*x$x
  x$x2&lt;-x$x^2
  
  # Set colours #
  
  blue&lt;-rgb(0.8, 0.8, 1, alpha=0.25)
  clear&lt;-rgb(1, 0, 0, alpha=0.0001)
  
  # Define region to fill #
  
  x$fill &lt;- "no fill"
  x$fill[(x$x2 &gt; x$twox) &amp; (x$x &lt;= 3 &amp; x$x &gt;= 2)] &lt;- "fill"
  
  # Plot #
  
  ggplot(x, aes(x=x, y=twox)) + 
    geom_line(aes(y = twox)) + 
    geom_line(aes(y = x2)) +
    geom_area(aes(fill=fill)) +
    scale_y_continuous(expand = c(0, 0), limits=c(0,20)) +
    scale_x_continuous(expand = c(0, 0), limits=c(0,5)) + 
    scale_fill_manual(values=c(clear,blue))
  </code></pre>
  
  <p>The result is the following which just shades the region under the line y=2x, and this no matter what the x-value - why?</p>
  
  <p><img src="https://i.stack.imgur.com/8JzHu.png" alt="enter image description here"></p>