Python/matplotlib : getting rid of matplotlib.mpl warning

前端 未结 4 1323
长情又很酷
长情又很酷 2020-12-16 17:14

I am using matplotlib using python 3.4. When I start my program, I have the following warning message:

C:\\Python34-32bits\\lib\\site-packages\\matplo

相关标签:
4条回答
  • 2020-12-16 17:24

    I was able to suppress that warning with the code below:

    import warnings
    
    warnings.filterwarnings("ignore",category=UserWarning)
    
    0 讨论(0)
  • 2020-12-16 17:27

    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)
    
    0 讨论(0)
  • 2020-12-16 17:38

    you can temporarily suppress a warning, when importing

    import warnings
    
    def fxn():
        warnings.warn("deprecated", DeprecationWarning)
    
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        fxn()
    
    0 讨论(0)
  • 2020-12-16 17:41

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

    import warnings
    import matplotlib.cbook
    warnings.filterwarnings("ignore",category=matplotlib.cbook.mplDeprecation)
    
    0 讨论(0)
提交回复
热议问题