Linux/mac下面查看支持的字体
fc-list 查看字体
fc-list :lang=zh 查看中文字体 (冒号前有空格)
一、(支持Windows/linux)
import matplotlib
font = {
'family':'Microsoft Yahei',
"size":"10"
}
matplotlib.rc("font",**font)
如果报错not found 需要下载字体并把字体放入".../matplotlib/mpl-data/fonts/ttf/"下
然后删除~/.cache/matplotlib目录
二、(支持windows/linux/mac)
先获取中文字体地址
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="字体地址")
plt.xticks(x,x_ch,fontproperties = my_font)
plt.show()