Mayavi中的mesh
函数接受representation
关键字,该关键字允许将曲面视为三角形线框网格。如何使用mlab.pipeline.iso_surface
或mlab.contour3d
?
例如,我想达到效果:
import numpy as np
from mayavi import mlab
# Create image volume with sphere as zero level surface.
x,y,z = np.mgrid[-20:21, -20:21, -20:21].astype(np.float)
vol = np.sqrt(x**2 + y**2 + z**2) - 7
# Visualize the level surface.
sf = mlab.pipeline.scalar_field(vol)
mlab.pipeline.iso_surface(sf, contours=[0.0],
representation='wireframe')
mlab.show()
当然,此代码无法运行,因为representation
函数不存在iso_surface
关键字参数。