I found that the hist2d generates the density heatmap extremely fast.
When I want to reproduce the function and then apply to 3d to generate 3d density heatmap, it seems extremely slow (which should be caused by the slow python 'for' loop):
xi, yi = np.mgrid[-30:30:200*1j, -30:30:200*1j]
step = 60/200
count_grid = np.full_like(yi, np.nan)
for idx, value in np.ndenumerate(x):
mask_grid = (x_mask>xi[idx]-0.5*step) & (x_mask<xi[idx]+0.5*step) & (y_mask>yi[idx]-0.5*step) & (y_mask<yi[idx]+0.5*step)
count_grid[idx] = len(x_mask[mask_grid])
So I would like to find hist2d's source code, which provided by matplotlib is a boilerplate one, I do not know where to find the useful one.
Anyone can help?