title: Fitting to Poisson histogram
body: <p>I am trying to fit a curve over the histogram of a Poisson distribution that looks like this
  <img src="https://i.stack.imgur.com/Bpt0E.png" alt="histo"></p>
  
  <p>I have modified the fit function so that it resembles a Poisson distribution, with the parameter t as a variable. But the curve_fit function can not be plotted and I am not sure why.</p>
  
  <pre><code>def histo(bsize):
      N = bsize
      #binwidth
      bw = (dt.max()-dt.min())/(N-1.)
      bin1 = dt.min()+ bw*np.arange(N)
      #define the array to hold the occurrence count
      bincount= np.array([])
      for bin in bin1:
          count = np.where((dt&gt;=bin)&amp;(dt&lt;bin+bw))[0].size
          bincount = np.append(bincount,count)
      #bin center
      binc = bin1+0.5*bw
      plt.figure()
      plt.plot(binc,bincount,drawstyle= 'steps-mid')
      plt.xlabel("Interval[ticks]")
      plt.ylabel("Frequency")
  histo(30)
  plt.xlim(0,.5e8)
  plt.ylim(0,25000)
  import numpy as np
  from scipy.optimize import curve_fit
  delta_t = 1.42e7
  def func(x, t):
      return t * np.exp(- delta_t/t) 
  popt, pcov = curve_fit(func, np.arange(0,.5e8),histo(30))
  plt.plot(popt)
  </code></pre>