title: Python 2.7: Trouble fitting a Poisson distributed histogram; curve drops off quickly
body: <p>I have a discrete set of data which looks Poisson distributed between 0 and 90. I'm trying to curve fit the data. My code is the following:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import matplotlib
  matplotlib.style.use('ggplot')
  import numpy as np
  from scipy.stats import poisson
  from scipy.optimize import curve_fit
  from scipy.misc import factorial
  
  plt.figure(figsize = (10, 10))
  
  entries, bin_edges, patches = plt.hist(data, bins = 90, range = [1, 90], normed = True)
  bin_middles = 0.5*(bin_edges[1:] + bin_edges[:-1])
  
  def poisson(k, lamb):
      return (lamb**k/factorial(k)) * np.exp(-lamb)
  
  params, cov = curve_fit(poisson, bin_middles, entries)
  x_plot = np.linspace(1, 90, 90)
  
  plt.plot(x_plot, poisson(x_plot, *params), 'b--', lw = 2)
  plt.axvline(np.mean(data), linestyle = '--', color = 'g')
  plt.ylim(0, max(entries)+max(entries)/4)
  plt.xlim([0, max(x_plot)])
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/GwXTk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GwXTk.png" alt="enter image description here"></a></p>
  
  <p>I can't identify why the curve is sitting to the left and the values are extremely small. Thanks for any help!</p>