One - One Code All

Blog Content

matplotlib.category: Using categorical units to plot a list of strings

Python   2020-12-28 21:36:49

matplotlib使用过程中报错: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.

解决示例:

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



上一篇:python读取环境变量
下一篇:visual studio code 打开当前文件所在终端插件Terminal Here

The minute you think of giving up, think of the reason why you held on so long.