首页 > 解决方案 > 来自 3D 数据 python 的 2D 热图

问题描述

我正在尝试从 3d 数据集生成 2D 热图/强度图,例如

x,     y,    z:
0      0     2
1      0     4
1      1     2
2      0     3
2      1     4 ..

其中 (x,y) 是网格点,z 是我的函数 z = f(x,y) 的幅度。到目前为止,我已经将其可视化为 3d+heatmap 通过

ax = plt.axes(projection="3d")
ax.scatter3D ( x,y z, c=z, cmap ="hsv")

我现在想使用带有热图的二维图来可视化这一点。我努力了

sc = plt.scatter(x,y, c=z, cmap ="hsv")
cbar = fig.colorbar(sc)
plt.show()

然而,我的 90% 的 z 值分布在 0 附近,其余的则显示我感兴趣的结构。使用散点图,10% 完全被构成背景的 90% 所掩盖。我怎样才能更有效地可视化这样的 3D 数据集,其中大部分数据分布在某个均值附近,而我对偏离均值的数据点感兴趣?

标签: python3dheatmapcolormap

解决方案


您可能正在寻找等高线类型的图。看看是不是你要找的:

情节库:https ://plotly.com/python/contour-plots/

Matplotlib 库:https ://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.contour.html


推荐阅读