I have two really large arrays that can't fit in memory at once. I am interested in plotting a 2D histogram of these two arrays with a colorbar. In my case I loop over subsequent chunks of arrays and keep appending first data to x and y, such that:
n_bins=99
histogram = np.zeros(shape=(1,n_bins), dtype=np.float64)
histogramy = np.zeros(shape=(1,n_bins), dtype=np.float64)
and below happens in each (for) loop iteration when desired chunk length of x is reached:
add_coip, _ = np.histogram(np.asarray(x)[:], bins=(xedges))
add_coipy, _ = np.histogram(np.asarray(y)[:], bins=(yedges))
histogramx += add_coip.astype(np.float64)
histogramy += add_coipy.astype(np.float64)
x,y=[],[] # reset lists to append next chunk
Though I get histogramx and histogramy binned properly, I am unable to plot a 2D histogram using these arrays. Note that histogramx and histogramy doesn not contain data, rather a binned-version of the data. Any suggestions please?
PS: I understand using plt.bar as in this post but that's for a 1D plot!