用於做等高線圖你需要你的數據插值到規則網格http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data
一個簡單的例子:
>>> xi = linspace(min(X), max(X))
>>> yi = linspace(min(Y), max(Y))
>>> zi = griddata(X, Y, Z, xi, yi)
>>> contour(xi, yi, zi)
爲表面http://matplotlib.sourceforge.net/examples/mplot3d/surface3d_demo.html
>>> from mpl_toolkits.mplot3d import Axes3D
>>> fig = figure()
>>> ax = Axes3D(fig)
>>> xim, yim = meshgrid(xi, yi)
>>> ax.plot_surface(xim, yim, zi)
>>> show()
>>> help(meshgrid(x, y))
Return coordinate matrices from two coordinate vectors.
[...]
Examples
--------
>>> X, Y = np.meshgrid([1,2,3], [4,5,6,7])
>>> X
array([[1, 2, 3],
[1, 2, 3],
[1, 2, 3],
[1, 2, 3]])
>>> Y
array([[4, 4, 4],
[5, 5, 5],
[6, 6, 6],
[7, 7, 7]])
輪廓在3Dhttp://matplotlib.sourceforge.net/examples/mplot3d/contour3d_demo.html
>>> fig = figure()
>>> ax = Axes3D(fig)
>>> ax.contour(xi, yi, zi) # ax.contourf for filled contours
>>> show()
我發佈了一個如何將數據放入二維數組以便能夠使用matplotlib的表面圖的示例:http://stackoverflow.com/a/30539444/3585557。另外,看看這些相關/類似/重複的帖子:http://stackoverflow.com/q/9170838/3585557,http://stackoverflow.com/q/12423601/3585557,http://stackoverflow.com/ q /三百五十八萬五千五百五十七分之二千一百一十六萬一千八百八十四,http://stackoverflow.com/q/26074542/3585557,http://stackoverflow.com/q/28389606/3585557,http://stackoverflow.com/q/29547687/3585557 – 2015-05-30 13:16:44