title: Any way to create histogram with matplotlib.pyplot without plotting the histogram?
body: <p>I am using matplotlib.pyplot to create histograms. I'm not actually interested in the plots of these histograms, but interested in the frequencies and bins (I know I can write my own code to do this, but would prefer to use this package).</p>
  
  <p>I know I can do the following,</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  x1 = np.random.normal(1.5,1.0)
  x2 = np.random.normal(0,1.0)
  
  freq, bins, patches = plt.hist([x1,x1],50,histtype='step')
  </code></pre>
  
  <p>to create a histogram. All I need is <code>freq[0]</code>, <code>freq[1]</code>, and <code>bins[0]</code>. The problem occurs when I try and use,</p>
  
  <pre><code>freq, bins, patches = plt.hist([x1,x1],50,histtype='step')
  </code></pre>
  
  <p>in a function. For example,</p>
  
  <pre><code>def func(x, y, Nbins):
      freq, bins, patches = plt.hist([x,y],Nbins,histtype='step') # create histogram
  
      bincenters = 0.5*(bins[1:] + bins[:-1]) # center bins
  
      xf= [float(i) for i in freq[0]] # convert integers to float
      xf = [float(i) for i in freq[1]]
  
      p = [ (bincenters[j], (1.0 / (xf[j] + yf[j] )) for j in range(Nbins) if (xf[j] + yf[j]) != 0]
  
      Xt = [j for i,j in p] # separate pairs formed in p
      Yt = [i for i,j in p]
  
      Y = np.array(Yt) # convert to arrays for later fitting
      X = np.array(Xt)
  
      return X, Y # return arrays X and Y
  </code></pre>
  
  <p>When I call <code>func(x1,x2,Nbins)</code> and plot or print <code>X</code> and <code>Y</code>, I do not get my expected curve/values. I suspect it something to do with <code>plt.hist</code>, since there is a partial histogram in my plot.</p>