I have 5 points (x,y) and used matplotlib's histogram2d function to create a heatmap showing different colors denoting the density of each bin. How could I obtain the frequency of the number of points in the bins?
import numpy as np
import numpy.random
import pylab as pl
import matplotlib.pyplot as plt
x = [.3, -.3, -.3, .3, .3]
y = [.3, .3, -.3, -.3, -.4]
heatmap, xedges, yedges = np.histogram2d(x, y, bins=4)
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
plt.clf()
plt.imshow(heatmap, extent=extent)
plt.show()
pl.scatter(x,y)
pl.show()
Thus, using 4 bins, I would expect the frequencies in each bin to be .2, .2, .2, and .4