title: Plot a 3D bar histogram with python
body: <p>I have some x and y data, with which I would like to generate a 3D histogram, with a color gradient (bwr or whatever). </p>
  
  <p>I have written a script which plot the interesting values, in between -2 and 2 for both x and y abscesses: </p>
  
  <pre><code>import numpy as np
  import numpy.random
  import matplotlib.pyplot as plt
  
  # To generate some test data
  x = np.random.randn(500)
  y = np.random.randn(500)
  
  XY = np.stack((x,y),axis=-1)
  
  def selection(XY, limitXY=[[-2,+2],[-2,+2]]):
          XY_select = []
          for elt in XY:
              if elt[0] &gt; limitXY[0][0] and elt[0] &lt; limitXY[0][1] and elt[1] &gt; limitXY[1][0] and elt[1] &lt; limitXY[1][1]:
                  XY_select.append(elt)
  
          return np.array(XY_select)
  
  XY_select = selection(XY, limitXY=[[-2,+2],[-2,+2]])
  
  heatmap, xedges, yedges = np.histogram2d(XY_select[:,0], XY_select[:,1], bins = 7, range = [[-2,2],[-2,2]])
  extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
  
  
  plt.figure("Histogram")
  #plt.clf()
  plt.imshow(heatmap.T, extent=extent, origin='lower')
  plt.show()
  </code></pre>
  
  <p>And give this correct result: </p>
  
  <p><a href="https://i.stack.imgur.com/NGeRY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NGeRY.png" alt="enter image description here"></a></p>
  
  <p>Now, I would like to turn this into a 3D histogram. Unfortunatly I don't success to plot it correctly with <code>bar3d</code> because it takes by default the length of x and y for abscisse. </p>
  
  <p>I am quite sure that there is a very easy way to plot this in 3D with imshow. Like an unknow option...</p>