1
的我点的列表:使用轮廓和contourf
pointList = [ [x1,y1,z1], [x2,y2,z2], ... [xn,yn,zn]]
,我要画这组点的等高线图。
我尝试:
import matplotlib.pyplot as plt
pointList = [ [x1,y1,z1], [x2,y2,z2], ... [xn,yn,zn]]
x = [el[0] for el in pointList]
y = [el[1] for el in pointList]
z = [el[2] for el in pointList]
plt.contourf(x,y,z)
plt.show()
,但我有这样的例外:
TypeError: Input z must be a 2D array.
这很奇怪,因为matplotlib,我发现文档中:
Call signatures:
contour(Z)
make a contour plot of an array Z. The level values are chosen automatically.
contour(X,Y,Z)
X, Y specify the (x, y) coordinates of the surface
所以我不不明白为什么它会失败...
你的观点是否确实创造了一个表面? 'X'和'Y'是用于表面的唯一'x'和'y'值。它不打算用于分散数据 – Suever
不确定要理解。我应该怎么做才能“实际”创造一个表面? – rudy
可能重复的[散射轮廓](http://stackoverflow.com/questions/18764814/make-contour-of-scatter) – Suever