擅长:python、mysql、java
<p><code>plt.tricontourf(x,y,z)</code>是否满足您的要求?</p>
<p>它将绘制不规则间距数据(非直线网格)的填充等高线。</p>
<p>您可能还需要查看<code>plt.tripcolor()</code>。</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
x = np.random.rand(100)
y = np.random.rand(100)
z = np.sin(x)+np.cos(y)
f, ax = plt.subplots(1,2, sharex=True, sharey=True)
ax[0].tripcolor(x,y,z)
ax[1].tricontourf(x,y,z, 20) # choose 20 contour levels, just to show how good its interpolation is
ax[1].plot(x,y, 'ko ')
ax[0].plot(x,y, 'ko ')
plt.savefig('test.png')
</code></pre>
<p><img src="https://i.stack.imgur.com/zivZZ.png" alt="tripcolor and tricontourf example"/></p>