Python/matplotlib : getting rid of matplotlib.mpl warning

放肆的年华 提交于 2019-11-30 12:11:18

You can suppress that particular warning, which is probably the preferred way:

import warnings
import matplotlib.cbook
warnings.filterwarnings("ignore",category=matplotlib.cbook.mplDeprecation)

you can temporarily suppress a warning, when importing

import warnings

def fxn():
    warnings.warn("deprecated", DeprecationWarning)

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    fxn()

It would be useful to see the code, however remember to set the parameters of the plot first, only then initialize the plot.

Exemple, what you may have done:

plt.pcolormesh(X, Y, Z)
plt.axes().set_aspect('equal')

What you have to do:

plt.axes().set_aspect('equal')
plt.pcolormesh(X, Y, Z)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!