Why am I getting this matplotlib error for plotting a categorical variable?

I keep getting the following message after plotting the following data. Is there a way to not get this message ?
Code -

data = {'Monday': 154, 'Thursday': 153, 'Tuesday': 151, 'Sunday': 144, 'Wednesday': 139, 'Friday': 130, 'Saturday': 120}
names = list(data.keys())
values = list(data.values())
fig, axs = plt.subplots(figsize=(9, 3))
axs.bar(names, values)

Message -
2021-01-04 12:30:15.586 INFO matplotlib.category: Using categorical units to plot a list of strings that are all parsable as floats or dates. If these strings should be plotted as numbers, cast to the appropriate data type before plotting.

Do you mean for those to be dates, or “categories”? This is happening because people would put in dates as strings, and then be surprised that they are treated as categories. So this info message is meant to dispel the confusion. However, you must have set your logging level to INFO or higher to see this message. If you need higher level logging but do not wish to have matplotlib at that level, you can do:

import matplotlib.pyplot as plt
import logging

logging.basicConfig(level='INFO')

mlogger = logging.getLogger('matplotlib')
mlogger.setLevel(logging.WARNING)

data = {'Monday': 154, 'Thursday': 153, 'Tuesday': 151, 'Sunday': 144, 'Wednesday': 139, 'Friday': 130, 'Saturday': 120}
names = list(data.keys())
values = list(data.values())
fig, axs = plt.subplots(figsize=(9, 3))
axs.bar(names, values)
plt.show()

or plt.set_loglevel('WARNING') also works as a helper.

as a side note, you shouldn’t need to cast to list. The following should work:

%matplotlib inline
import matplotlib.pyplot as plt

data = {'Monday': 154, 'Thursday': 153, 'Tuesday': 151, 'Sunday': 144, 'Wednesday': 139, 'Friday': 130, 'Saturday': 120}
fig, axs = plt.subplots(figsize=(9, 3))
axs.bar(data.keys(), data.values())

I was using this as example - Plotting categorical variables — Matplotlib 3.3.3 documentation
Thank you for your tips. :slight_smile:

 plt.set_loglevel('WARNING') 

this worked for me. thank you somuch!