How to create a 3d Heatmap from a discrete data set in Python?

安稳与你 提交于 2020-01-23 03:47:06

问题


I have a large dataset of the form [(X1, Y1, Z1, VALUE1), (X2, Y2, Z2, VALUE2)...]. The geometry of the points is the surface of a cylinder, while there are many discrete points they come nowhere near being a full mesh.

I would like to create a basic plot, where each of the points is given an intensity of a color (like a heatmap) based on how high its value is, and then the colors are smoothed to some degree to create a cohesive surface rather than discrete points

I am currently using matplotlib, however, I would also use other libraries if necessary.

I have looked into both surface plots and Tri-Surface plots but neither seem to do what I want (although the documentation for plot_trisurf() is a little confusing so maybe it is still a possibility). I have also looked at this post: 3D discrete heatmap in matplotlib.

And while the set up is mostly the same, I would like to have a more cohesive surface plot rather than a 3d Tetris set up. The original answer seems pretty close to my desired solution, however, I would like the colors to be based on VALUE rather than Z and if possible for there to be color smoothing between the sections.


回答1:


Depending on how dense your point cloud is you may be able to get what you want with this (adjust the size parameter, s, to fill out the plot best for your data):

from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.scatter(X, Y, Z, c=Value, lw=0, s=20)
plt.show()



来源:https://stackoverflow.com/questions/51254419/how-to-create-a-3d-heatmap-from-a-discrete-data-set-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!