2016-07-08 50 views
0

繪製等高我有X coordinatesY coordinatesZcoordinates,每個存儲在與Matplotlibn x 1 . (n rows,1 column) .The等值線圖的陣列允許只有"*X and Y must both be 2-D with the same shape as Z, or they must both be 1-D such that len(X) is the number of columns in Z and len(Y) is the number of rows in Z.*"錯誤而在Matplotlib

我該如何解決這個問題,以情節?
也應該可以訪問相應的x,y,z值。
混合數據點將導致我的情節錯誤。

+0

您如何期望contour圖與1D z-座標(假設z是您在x-y平面上繪製的圖)相似?你確定你不是在尋找散點圖或3d線圖嗎? –

+0

您可以通過提供代碼的最小工作示例來改善此問題,該代碼重現了您遇到的錯誤。 –

回答

0

我知道的方法是在網格評價Z,X和Y組成:

X, Y = np.meshgrid(x, y) 
plt.plot(X, Y, z) 
z = <evaluate over X, Y> 
plt.contour(X, Y, z) 
plt.show() 

This解釋這一點更好

+1

您假定z被定義爲可以在新網格上評估的函數。這可能是一個山的點高度測量的列表,所以這種方法不會工作。 – VBB

0

輪廓預計柵格數據。這matplotlib教程完美地解釋它: http://matplotlib.org/examples/pylab_examples/griddata_demo.html。 另請參閱Make contour of scatter

+2

雖然在這種情況下不太可能發生,但是總是引用重要鏈接中最相關的部分,以防萬一目標網站無法訪問或永久脫機。* [answer guidelines](http:// stackoverflow。 com/help/how-to-answer) –

+0

感謝 - 請記住:) 對於這個特定的問題,正如您已經指出的那樣,這裏不太可能,因爲這些網站是stackoverflow本身和matplotlib。 – VBB