如何在Python中绘制数据立方体
我想知道是否有一种方法可以在 Python 中绘制数据立方体。我的意思是每个点都有三个坐标
x=part.points[:,0]
y=part.points[:,1]
z=part.points[:,2]
对于每个点我都有一个标量场 t(x,y,z)
我想绘制一个 3D 数据立方体来显示该点的位置以及每个点的成比例的颜色到该点的标量场 t。
我尝试使用 histogramdd 但没有成功。
I was wondering if there's a way to plot a data cube in Python. I mean I have three coordinate for every point
x=part.points[:,0]
y=part.points[:,1]
z=part.points[:,2]
And for every point I have a scalar field t(x,y,z)
I would like to plot a 3D data cube showing the position of the point and for every point a color which is proportional to the scalar field t in that point.
I tried with histogramdd but it didn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 matplotlib。
这里有一个工作示例(可以移动!):
您可能必须自定义标量的关系具有相应颜色的值。
Matplotlib 的外观非常漂亮,但当您有很多点时,绘制和移动这些 3D 绘图的速度可能会很慢。在这些情况下,我曾经使用 Gnuplot 由 gnuplot.py。 Gnuplot 也可以直接用作子进程,如此处和此处。
You can use matplotlib.
Here you have a working example (that moves!):
You probably have to customize the relation of your scalar values with the corresponding colors.
Matplotlib has a very nice look but it can be slow drawing and moving these 3D drawings when you have many points. In these cases I used to use Gnuplot controlled by gnuplot.py. Gnuplot can also be used directly as a subprocess as shown here and here.
另一个选项是 Dots 图,由 MathGL。它是 GPL 绘图库。添加如果以位图格式(PNG、JPEG、GIF 等)保存,则不需要太多内存。
Another option is Dots plot, produced by MathGL. It is GPL plotting library. Add it don't need many memory if you save in bitmap format (PNG, JPEG, GIF and so on).