ggplot2 stacked area chart not filling between years
<p>I have data structured as follows (this is merely an example):</p>

<pre><code>    year    company cars
    2011    toyota  609
    2011    honda   710
    2011    ford    77
    2011    nissan  45
    2011    chevy   11
    2012    toyota  152
    2012    honda   657
    2012    ford    128
    2012    nissan  159
    2012    chevy   322
    2013    toyota  907
    2013    honda   656
    2013    ford    138
    2013    nissan  270
    2013    chevy   106
    2014    toyota  336
    2014    honda   957
    2014    ford    204
    2014    nissan  219
    2014    chevy   282
</code></pre>

<p>I want to make a stacked area chart. With one data set formatted exactly as above, the formula <code>ggplot(data, aes(x=year,y=cars, fill=company)) + geom_area()</code> fills in the areas between the years nicely, like so:</p>

<p><a href="https://i.stack.imgur.com/R8DOL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R8DOL.png" alt="enter image description here"></a></p>

<p>However, with another data set formatted exactly the same way and generated using exactly the same ggplot code, only using the new data source, <code>ggplot(data2, aes(x=year,y=cars, fill=company)) + geom_area()</code>, the chart does not fill in the area between the years and creates a mess, like so:</p>

<p><a href="https://i.stack.imgur.com/uuWVi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uuWVi.png" alt="enter image description here"></a></p>

<p>You'll notice at each year, all the points connect. The odd gaps are only between years.</p>

<p>Does anyone have any suggestions about the possible source of this error?</p>