如何使用Matplotlib在等高线图上设置更多的自动级别?

2024-04-24 10:36:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在绘制下面的图片

enter image description here

使用以下代码

plt.pcolormesh(ticks[0], ticks[2], np.transpose(potential), zorder=0)
plt.contour(ticks[0], ticks[2], np.transpose(potential), zorder=1, colors='black', linestyles='solid')
plt.pcolormesh(ticks[0], ticks[2], np.transpose(rectangle), cmap=ListedColormap([[1, 1, 1, 0], [0, 0, 0, 1]]), zorder=2)

现在我想要更多的轮廓层次。如果我编码

^{pr2}$

(或其他整数)我收到警告

/opt/anaconda3/lib/python3.5/site-packages/matplotlib/contour.py:1180: UserWarning: No contour levels were found within the data range.

一点轮廓都没有

enter image description here

如何克服?在


Tags: 代码np绘制图片plt轮廓potentialcontour