[英]Python 2D-plotting of already binned arrays
I have two really large arrays that can't fit in memory at once.我有两个非常大的 arrays 不能同时放入 memory。 I am interested in plotting a 2D histogram of these two arrays with a colorbar.
我有兴趣用彩条绘制这两个 arrays 的二维直方图。 In my case I loop over subsequent chunks of arrays and keep appending first data to
x
and y
, such that:在我的情况下,我遍历 arrays 的后续块并继续将第一个数据附加到
x
和y
,这样:
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:当达到所需的 x 块长度时,在每个 (
for
) 循环迭代中发生以下情况:
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.虽然我得到了
histogramx
和histogramy
正确分箱,但我无法使用这些 arrays plot 二维直方图。 Note that histogramx
and histogramy
doesn not contain data, rather a binned-version of the data.请注意,
histogramx
和histogramy
不包含数据,而是数据的分箱版本。 Any suggestions please?请问有什么建议吗?
PS: I understand using plt.bar
as in this post but that's for a 1D plot! PS:我理解在这篇文章中使用
plt.bar
但那是一维图!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.