豆粑粑 mayavi 3d contour surface python
画3D contour surface,matlab,暂时是实现不了。
用python 下的mayavi2实现的,如何安装完全按官网的教程。
运行一个例子,小华丽。
from scipy.interpolate import griddata
import numpy as np
# Create some test data, 3D gaussian, 200 points
dx, pts = 2, 50j
N = 500
R = np.random.random((N,3))*2*dx - dx
V = np.exp(-( (np.sin(R)**2).sum(axis=1)) )
print "Rsize=",np.shape(R)
print "R=" ,R
print "V=" ,V
# Create the grid to interpolate on
X,Y,Z = np.mgrid[-dx:dx:pts, -dx:dx:pts, -dx:dx:pts]
# Interpolate the data
F = griddata(R, V, (X,Y,Z))
#np.savetxt('./F.txt',F)
print "F size", np.size(F)
print "grid val= ",F
from mayavi import mlab
mlab.contour3d(F,contours=8,opacity=.2 )
页:
[1]