title: Fill under line curve
body: <p>For the sample dataset below, I would like to just plot the y as a smooth line with fill under the line using R. </p>
  
  <p>I am able to get smooth line but not the color filled curve. Could someone please help me here?</p>
  
  <pre><code>date, y
  2015-03-11, 71.12
  2015-03-10, 34.0
  2015-03-09, 11.1
  2015-03-08, 9.62
  2015-03-07, 25.97
  2015-03-06, 49.7
  2015-03-05, 38.05
  2015-03-04, 38.05
  2015-03-03, 29.75
  2015-03-02, 35.85
  2015-03-01, 30.65
  </code></pre>
  
  <p>The code I used to plot the smooth line is as follows. I am unable to get fill the portion under the line with a color</p>
  
  <pre><code>y &lt;- df$y
  x &lt;- 1:length(y)
  
  plot(x, y, type='n')
  smooth = smooth.spline(x, y, spar=0.5)
  lines(smooth)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/fxtVW.png" alt="enter image description here"></p>
  
  <p><strong>EDIT</strong>
  Using the polygon function does not give what is expected. The shaded area should be below the line not above</p>
  
  <pre><code>with(smooth, polygon(x, y, col="gray"))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/12HA0.png" alt="enter image description here"></p>