Python/matplotlib : getting rid of matplotlib.mpl warning

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

import warnings

warnings.filterwarnings("ignore",category=UserWarning)

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()