title: Filling in the area under a line graph in ggplot2: geom_area()
body: <p>For the data:</p>
  
  <pre><code>    def.percent period  valence
  1   6.4827843   1984-1985   neg
  2   5.8232425   1985-1986   neg
  3   -2.4003260  1986-1987   pos
  4   -3.5994399  1987-1988   pos
  </code></pre>
  
  <p>If I add a line to the points, how can I use ggplot2 to color the area under the line [ geom_area() ] with different colors for the valence values "neg" and "pos"?</p>
  
  <p>I tried this:</p>
  
  <pre><code>ggplot(data, aes(x=period, y=def.percent, group = 1)) +
  geom_area(aes(fill=valence)) +
  geom_line() + geom_point() + geom_hline(yintercept=0)
  </code></pre>
  
  <p>But R returns the error:</p>
  
  <pre><code>Error: Aesthetics can not vary with a ribbon
  </code></pre>
  
  <p>This same code works for a different dataset, I don't understand what is happening here, for example:</p>
  
  <pre><code>library(gcookbook) # For the data set
  cb &lt;- subset(climate, Source=="Berkeley")
  cb$valence[cb$Anomaly10y &gt;= 0] &lt;- "pos"
  cb$valence[cb$Anomaly10y &lt; 0] &lt;- "neg"
  
  ggplot(cb, aes(x=Year, y=Anomaly10y)) +
    geom_area(aes(fill=valence)) +
    geom_line() +
    geom_hline(yintercept=0)
  </code></pre>