title: R/ggplot2: how to match legend and plot colors in overlapping area plots?
body: <p>I have two area plots (call them 'blue' and 'green') where the <code>green</code> is mostly under the <code>blue</code> plot, but on a very few points, it is higher than the <code>blue</code> plot. I want to use transparency say <code>alpha = 0.2</code> for both, and also be able to specify the colors for each. My problem now is that since the <code>green</code> plot is mostly under the <code>blue</code> plot, its area mostly has the <em>blended</em> color <code>blue</code> + <code>green</code> = some other color, and in only a few places shows its "true" green color. However the <em>legend</em> of course shows the <code>blue</code> plot mapped to blue and the <code>green</code> plot mapped to green. Problem is, when someone looks at the graph, they will be confused since the <code>green</code> plot mostly looks non-green (because it's overlapping with blue most of the time).</p>
  
  <p>Here's my code (super simplified version of my real application).</p>
  
  <pre><code>df &lt;- data.frame( date = 1:5, blue = 10, green = c(1,5,11,5,1))
  df.m &lt;- melt( df, id = 'date', variable_name = 'type' )
  df.m$type &lt;- ordered( df.m$type, c('green', 'blue'))
  
  ggplot(df.m, aes(date,value)) +
    geom_area( aes(fill = type),  position = 'identity', alpha = 0.2) +
    scale_fill_manual ( values = c('green', 'blue') )
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/7NCgX.png" alt="enter image description here"></p>
  
  <p>As you can see, the "true green" area of the green plot is very small, so the legend color for <code>green</code> doesn't really match the majority of the <code>green</code> plot. This is of course the right behavior by design, but I am wondering if there is some way I can get the legend colour for <code>green</code>, and the overlapping <code>blue+green</code> color to match up. One thing I did try is to transform the <code>blue</code> variable to <code>blue - green</code>, and then make the area plots <em>stacked</em> (with <code>position = "stack"</code>). This almost works but isn't quite satisfactory because the color on the dates where the new <code>blue</code> variable is negative looks strange. </p>
  
  <p>Are there other ways to get the legend color for <code>green</code> and the color of the "overlapping blue/green" area to match up? Maybe a way to directly specify the legend color? Any help appreciated!</p>