title: Numpy.histogram joining bins
body: <p>I have some image data that I have plotted in a histogram using numpy as shown in the code below. The problem I am having is that the x axis goes up in steps of 1, but the bin width is approximately 1.3 (I roughly calculated by zooming in and looking at the bin width). </p>
  
  <p>This leads to a histogram which looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Hhxi9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hhxi9.png" alt="enter image description here"></a></p>
  
  <p>As you can see at certain points the histogram goes down to zero. If I zoom in, the points at which the value is 0 are NOT integers. Because my data are integers the number 550.8 will obviously appear 0 times which is causing the histogram to have the appearance above (I think).</p>
  
  <p>I can get around this problem if I increase the number of bins from 100 to 1000. This leaves me with the histogram below:</p>
  
  <p><a href="https://i.stack.imgur.com/0yizg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0yizg.png" alt="enter image description here"></a> </p>
  
  <p>So I've finally got to my question (apologies for the long post!)...
  Is there a way to join the bins (when using a large number like I am to get around my initial problem) using np.histogram.
  I suppose this is just aesthetics and it isn't essential but it would look better.</p>
  
  <p>There are other posts on here which I have looked at, but almost all are using <code>plt.hist</code> for their histogram as opposed to <code>np.histogram</code>.</p>
  
  <p>My code:</p>
  
  <pre><code>def histo():
  
      heights,edges = np.histogram(data, bins=100, range=(minvalue,maxvalue))
      edges = edges[:-1]+(edges[1]-edges[0]) ### not entirely sure what this line is actually doing
  
      fig, ax = plt.subplots()
      ax.plot(edges,heights)                                                 
  
      ax.set(title=title, xlabel='ADC Value(DN/40)', ylabel='Frequency')
  
      #do some analysis of the data between two clicks
  
      point1, point2 = fig.ginput(2)                                          
      ax.axvspan(point1[0], point2[0], color='blue', alpha=0.5)            
      mask = (edges&gt;point1[0]) &amp; (edges&lt;point2[0])
  
      ## more analysis code ##       
  
  
  data = someimage_data
  
  histo()
  </code></pre>