在Python中打印和填充三维体积
我正在使用Python处理一些3D(体积)数据,对于每个四面体,我不仅有顶点的坐标,还有一个第四维,它是该四面体体积的一些参数值 例如:在Python中打印和填充三维体积,python,python-3.x,numpy,matplotlib,scipy,Python,Python 3.x,Numpy,Matplotlib,Scipy,我正在使用Python处理一些3D(体积)数据,对于每个四面体,我不仅有顶点的坐标,还有一个第四维,它是该四面体体积的一些参数值 例如: # nodes coordinates that defines a tetrahedron volume: x = [0.0, 1.0, 0.0, 0.0] y = [0.0, 0.0, 1.0, 0.0] z = [0.0, 0.0, 0.0, 1.0] # Scaler value of the potential for the given volum
# nodes coordinates that defines a tetrahedron volume:
x = [0.0, 1.0, 0.0, 0.0]
y = [0.0, 0.0, 1.0, 0.0]
z = [0.0, 0.0, 0.0, 1.0]
# Scaler value of the potential for the given volume:
c = 100.0
我想绘制一个3D体积(由节点坐标给出),填充一些纯色,表示给定的值C
在Python3.6中如何使用其绘图库实现这一点?您可以使用
mayavi.mlab.triangal\u mesh()
:
谢谢!还有其他图书馆吗?因为我遇到了一些问题。
from mayavi import mlab
from itertools import combinations, chain
x = [0.0, 1.0, 0.0, 0.0, 2.0, 3.0, 0.0, 0.0]
y = [0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0]
z = [0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 0.0, 3.0]
c = [20, 30]
triangles = list(chain.from_iterable(combinations(range(s, s+4), 3) for s in range(0, len(x), 4)))
c = np.repeat(c, 4)
mlab.triangular_mesh(x, y, z, triangles, scalars=c)