简体   繁体   中英

2D Heatmap from 3D data python

I am trying to produce a 2D heatmap/intensity plot from a 3d dataset with eg

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). So far, I have visualized this as 3d+heatmap via

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. 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. 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 ?

Probably, you are looking for Contour type of plots. See if it's what you are looking for:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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