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