matplotlib各种样例
用啥样子的图直接去找就完了
关于图中不显示汉字的问题
解答:
https://zhuanlan.zhihu.com/p/104081310
简要说明
在前面加入两行代码
import matplotlib
matplotlib.rc('font', family='AR PL UKai CN')
通过源码可以发现是matplotlib中内置方法matplotlib.rc中可以接收字体
matplotlib.rc("font",family='MicroSoft YaHei',weight="bold")
MicroSoft为字体微软雅黑,如果报错,则说明库中没有这个字体,可以自己查看具体的字体。
查看系统所有字体的代码
# 查询当前系统所有字体
from matplotlib.font_manager import FontManager
import subprocess
mpl_fonts = set(f.name for f in FontManager().ttflist)
print('all font list get from matplotlib.font_manager:')
for f in sorted(mpl_fonts):
print('\t' + f)
找到其中的中文字体(CN )然后填入即可。