慕容森
使用tricontourf:import matplotlib.tri as triimport matplotlib.pyplot as plt
triang = tri.Triangulation(x, y)plt.tricontour(x, y, z, 15, linewidths=0.5, colors='k')plt.tricontourf(x, y, z, 15)旧回复:使用以下函数转换为contourf所需的格式:from numpy import linspace, meshgridfrom matplotlib.mlab import griddatadef grid(x, y, z, resX=100, resY=100):
"Convert 3 column data to matplotlib grid"
xi = linspace(min(x), max(x), resX)
yi = linspace(min(y), max(y), resY)
Z = griddata(x, y, z, xi, yi)
X, Y = meshgrid(xi, yi)
return X, Y, Z现在你可以这样做:X, Y, Z = grid(x, y, z)plt.contourf(X, Y, Z)