title: matplotlib fill under LOWESS curve
body: <p>I have a plot for which I'd like to fill the area under the LOWESS line used to smooth a histogram. In <code>matplotlib</code> I believe that <code>plt.fill_between()</code> should be the way to go, but for some reason the sample code I have isn't doing what I was expecting; it's filling some bits but those are staggered and do not start from <code>y=0</code>. Any ideas on how to make this work?</p>
  
  <pre><code>import numpy as np
  import statsmodels.api as sm
  import matplotlib.pyplot as plt
  
  a = np.loadtxt('numbers.tt')
  a = a[~np.isnan(a)]
  a[:20]
  # array([ 0.04184204,  0.07509347, -0.00443857, -0.03590184, -0.0294351 ,
  #       -0.02969616, -0.02780433, -0.02362442, -0.04242367, -0.01171937,
  #       -0.0208392 , -0.02976209, -0.03771409, -0.0261862 , -0.04404418,
  #        0.00259364, -0.01267109, -0.01128568, -0.00380218, -0.03742523])
  fig, ax = plt.subplots()
  y, bins, _ = ax.hist(a, bins=100, color='w')
  x = 0.5 * (bins[1:] + bins[:-1])
  lowess = sm.nonparametric.lowess(y, x, frac=0.1)
  _ = ax.plot(lowess[:, 0], lowess[:, 1])  # draw line
  _ = ax.fill_between(lowess[:, 0], 0, lowess[:, 1])  # draw fill from y=0 to y value in lowess
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/SeYLX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SeYLX.png" alt="enter image description here"></a></p>