x, y = np.random.randn(2, 100) H, xedges, yedges = np.histogram2d(x, y, bins=(5, 8)) H.shape, xedges.shape, yedges.shape # ((5,8), (6,), (9,)) # We can now use the Matplotlib to visualize this 2-dimensional histogram: extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]] import matplotlib.pyplot as plt plt.imshow(H, extent=extent) # plt.show()