title: Scaling of fitted pdf for a histogram
body: <p>I'm working on some time series data and I tried to fit the data with a gamma distribution. But the problem is that the magnitude of fitted pdf is much lower than that of the histogram. Here are my code and plot. What is wrong with the plot?</p>
  
  <pre><code># the data
  data = contents[0][1:]
  
  # normalized histogram
  weights = np.ones_like(data)/len(data)
  plt.hist(data, bins = 20, color = 'w', edgecolor = 'black', alpha = 0.5, weights = weights)
  
  # fit with gamma distribution and plot the pdf
  dist = getattr(scipy.stats, 'gamma')
  param = dist.fit(data)
  x = np.linspace(min(data), max(data), 100)
  pdf_fit = dist.pdf(x, *param[:-2], loc = param[-2], scale = param[-1])
  plt.plot(x, pdf_fit/sum(pdf_fit), label = 'Gamma')
  plt.legend(loc = 'upper right')
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/fUFB2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fUFB2.png" alt="enter image description here"></a></p>