我的标量值位于极坐标中的点网格上。虽然我可以自由选择theta和phi角度,但r值由我的数据评估中的另一个步骤给出。如何使用mayavi绘制等值面和一些数据?
在那一刻,我正在尝试使用scipy.interpolate.griddata来获得一个eucledian网格,但它已经工作了几个小时已经没有结果......
from scipy import *
from enthought.mayavi import mlab
r_val = [0.5, 1.0, 1.5, 2.0] # externally given
r, theta, phi = mgrid[ \
r_val[0]:r_val[-1]:len(r_val)*1.j, \
0:pi:len(r_val)*1.j, \
0:2.*pi:len(r_val)*1.j ]
x = r*sin(theta)*cos(phi)
y = r*sin(theta)*sin(phi)
z = r*cos(theta)
# here would be the data
s = ones_like(x)
s *= r*r
# the x,y,z axes of this plot are r,theta,phi
mlab.contour3d(s)
# but I want them to be x,y,z!
# this does not work
#mlab.contour3d(x,y,z,s)
答案 0 :(得分:0)
请参阅http://permalink.gmane.org/gmane.comp.python.enthought.devel/20667
src = mlab.pipeline.scalar_scatter(x,y,z,s)
iso=mlab.pipeline.iso_surface(gs)