简体   繁体   English

来自 3D 数据 python 的 2D 热图

[英]2D Heatmap from 3D data python

I am trying to produce a 2D heatmap/intensity plot from a 3d dataset with eg我正在尝试从 3d 数据集生成 2D 热图/强度图,例如

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

where (x,y) are gridpoints and z is the amplitude of my function z = f(x,y).其中 (x,y) 是网格点,z 是我的函数 z = f(x,y) 的幅度。 So far, I have visualized this as 3d+heatmap via到目前为止,我已经将其可视化为 3d+heatmap 通过

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

I would like to visualize this now using a 2d plot with a heatmap.我现在想使用带有热图的 2d 图来可视化这一点。 I have tried我试过了

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

However, 90% of my z-values are distributed around 0 and the rest show the structure I am interested in. Using the scatter plot, the 10% are completely overshadowed by the 90% making up the background.然而,90% 的 z 值分布在 0 附近,其余显示我感兴趣的结构。使用散点图,10% 完全被构成背景的 90% 所掩盖。 How can I visualize such a 3D data set more efficiently, where most of the data is distributed around some mean and I am interested in the datapoints off the mean ?我如何更有效地可视化这样的 3D 数据集,其中大部分数据分布在某个平均值附近,而我对平均值以外的数据点感兴趣?

Probably, you are looking for Contour type of plots.可能,您正在寻找 Contour 类型的图。 See if it's what you are looking for:看看是不是你要找的:

Plotly library: https://plotly.com/python/contour-plots/绘图库: https ://plotly.com/python/contour-plots/

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM