簡體   English   中英

使用 binned_statistic_2d 繪制數據並求和顯示不需要的值

[英]Plotting data with binned_statistic_2d and sum showing unwanted values

我正在繪制地中海中閃電的能量分布,並使用 imshow 和 binned_statistic_2d 繪制我的數據。

我成功地繪制了閃電能量的平均值,但由於某種原因,我無法理解 imshow plot 在總和圖中看起來很奇怪(將不需要的區域塗成紫色,見左圖 plot)。

這是我正在使用的代碼-

 plot_3vars_sum = binned_statistic_2d(longs, lats, energies, statistic= 'sum', bins=[467, 175])
plot_3vars_mean = binned_statistic_2d(longs, lats, energies, statistic=np.mean, bins=[467, 175])
ax0.plot(long_points_med, lat_points_med)
ax1.plot(long_points_med, lat_points_med)
imshow_sum = ax0.imshow(plot_3vars_sum.statistic.T, origin='lower', extent=[min(longs), max(longs), min(lats), max(lats)])
imshow_mean = ax1.imshow(plot_3vars_mean.statistic.T, origin='lower', extent=[min(longs), max(longs), min(lats), max(lats)])
ax0.set_ylim(ymin=28, ymax= 47)
ax1.set_ylim(ymin=28, ymax= 47)
ax0.set_xlim(xmin=-7, xmax=37)
ax1.set_xlim(xmin=-7, xmax=37)
imshow_sum.set_clim(1, 100000)
imshow_mean.set_clim(1, 10000)
cb0 = fig.colorbar(imshow_sum, ax=ax0, shrink=0.6)
cb1 = fig.colorbar(imshow_mean, ax=ax1, shrink=0.6)
plt.title(f'This is {month} in 2009-10')
plt.show()

longs、lats 和 energies 只是浮點數的列表。

我得到的圖像是- 在此處輸入圖像描述

我嘗試忽略 nans 並將顏色條限制設置為 1 以上,但沒有任何效果...請問我可以尋求幫助嗎? 我被困住了。

提前致謝

這種行為的原因是,當使用均值時,一些 bin 包含“NaN”值,而“Sum”的結果包含 0。 我會嘗試找到一種方法使總和中的 0 變為 nan 。 我猜問題已經結束了? :-)

這種行為的原因是,當使用均值時,一些 bin 包含“NaN”值,而“Sum”的結果包含 0。 我會嘗試找到一種方法使總和中的 0 變為 nan 。 我猜問題已經結束了? :-)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM