Eli*_*sey 14 python 3d matplotlib
我正在尝试绘制一个3D表面,以适应python中的某些{x,y,z}点 - 理想情况下就像Mathematica ListSurfacePlot3D函数.到目前为止,我已经尝试plot_surface并且plot_wireframe在我的观点上无济于事.
只有轴渲染plot_surface.plot_wireframe给出了一堆波浪状的,隐约在对象的形状,但不是文档中显示的漂亮的排序:
与以下结果比较ListSurfacePlot3D:

这是一个最小的工作示例,使用我在这里发布的test.csv文件:
import csv
from matplotlib import pyplot
import pylab
from mpl_toolkits.mplot3d import Axes3D
hFile = open("test.csv", 'r')
datfile = csv.reader(hFile)
dat = []
for row in datfile:
dat.append(map(float,row))
temp = zip(*(dat))
fig = pylab.figure(figsize=pyplot.figaspect(.96))
ax = Axes3D(fig)
Run Code Online (Sandbox Code Playgroud)
然后,要么
ax.plot_surface(temp[0], temp[1], temp[2])
pyplot.show()
Run Code Online (Sandbox Code Playgroud)
要么
ax.plot_wireframe(temp[0], temp[1], temp[2])
pyplot.show()
Run Code Online (Sandbox Code Playgroud)
这是它渲染的方式plot_surface:
和使用plot_wireframe:
和使用ListSurfacePlot3D:

ali*_*i_m 12
plot_surface预计X,Y,在二维阵列的形式Z值,如将被返回np.meshgrid.当输入以这种方式定期网格化时,绘图函数隐式地知道表面中的哪些顶点彼此相邻,因此应该与边连接.但是,在您的示例中,您正在处理1D坐标向量,因此绘图函数需要能够确定应该连接哪些顶点.
该plot_trisurf函数不会做一个Delaunay三角剖分来确定哪些点应当以这样的方式,以避免"薄三角形"边缘被接合处理不规则间隔的点:
