title: can't properly fit poisson distribution in python
body: <p>i'm trying to plot poisson distribution with python3, but i'm having a problem with properly fitting the dataset.
  The function i have now is:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from scipy.optimize import curve_fit
  from scipy.misc import factorial
  
  #where valor is like [1,2,4,4,4,5,6,2,5,5,7,4,7,3,2,5,7,9,4,44,33,1,3,43,54,22,12,3,24,34,55,33]
  data = valor 
  
  entries, bin_edges, patches = plt.hist(data, bins=len(data), alpha=0.6, color='g', edgecolor='black', linewidth=1.2)
  
  bin_middles = 0.5*(bin_edges[1:] + bin_edges[:-1])
  
  def poisson(k, lamb):
      return (lamb**k/factorial(k)) * np.exp(-lamb)
  
  parameters, cov_matrix = curve_fit(poisson, bin_middles, entries) 
  
  
  x_plot = np.linspace(0,  len(data), 1000)
  
  plt.plot(x_plot, poisson(x_plot, *parameters), 'r-', lw=2)
  plt.show()
  </code></pre>
  
  <p>where valor is a variable dataset send by user. </p>
  
  <p>With this i try to plot the poisson distribution, using another plotting software i get this <a href="https://i.stack.imgur.com/doreh.png" rel="nofollow noreferrer">result</a></p>
  
  <p>but the plot output is <a href="https://i.stack.imgur.com/w6ePe.png" rel="nofollow noreferrer">this</a>.
  As you can see, the poisson line don't fit properly as in the first one.
  *Both datasets use the same patern of data. </p>