How to suppress matplotlib warning?

You can either suppress the warning messages as suggested by AndreL or you can resolve this specific issue and stop getting the warning message once and for all. If you want the latter, do the following.

Open your matplotlibrc file and search for axes.color_cycle. If you're getting the warning message it means that your matplotlibrc file should show something like this:

axes.color_cycle : b, g, r, c, m, y, k  # color cycle for plot lines

You should replace that line by this:

axes.prop_cycle : cycler('color', ['b', 'g', 'r', 'c', 'm', 'y', 'k'])

And the warning message should be gone.


Rather than hiding everything, you can also hide specific warnings. For instance if we want to hide only matplotlib warnings:

warnings.filterwarnings( "ignore", module = "matplotlib\..*" )

The filter can be customised down to the exact message and line number of the file in which the warning originates, let's say if it's just one warning that annoys you and not matplotlib as a whole. See https://docs.python.org/3/library/warnings.html for more details.


You can suppress all warnings:

import warnings
warnings.filterwarnings("ignore")

import pandas