title: Python 2d-histogram success rate per bin
body: <p>I have data in arrays x, y and w where 'x' and 'y' indicate position and 'w' is a weight of either 1 or 0 indicating success or failure. I'm trying to create a 2d histogram where each bin of the histogram is coloured based on the percentage of successes in that bin (i.e. # of successes in bin divided by total points in bin). I've played around with numpy.histogram2d quite a bit and can get density plots going, but this is not the same as the % of success scheme I'm aiming for. Please note normed=True in the numpy.histogram2d argument does not alleviate this problem.</p>
  
  <p>(To clarify on the difference, a density plot would indicate large 'colour value' if there is a larger number of successes in the bin regardless of how many failures are in the same bin. I would like to have the percentage of successes instead, so a large number of failures in the same bin would give a smaller 'colour value'. I apologise for poor terminology).</p>
  
  <p>Thank you very much to anyone who can help!</p>
  
  <p>Example of current code that doesn't do what I'm aiming for:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  plt.figure(1)
  H, xedges, yedges = np.histogram2d(x, y, bins=50, weights=w, normed=True)
  extent = [yedges[0], yedges[-1], xedges[-1], xedges[0]]
  plt.imshow(H, extent=extent,interpolation='nearest')
  plt.colorbar()
  plt.show()
  </code></pre>