mac
# 查看matplotlib支持的所有字体文件
import matplotlib
ttfs=sorted([f.name for f in matplotlib.font_manager.fontManager.ttflist])
for ttf in ttfs:
print(ttf)
# mac本身有中文自体库,可以直接设置中文字体,执行完图表就可以展示中文
import matplotlib.pyplot as plt
plt.rcParams["font.family"] = 'Arial Unicode MS'
mac安装字体可以通过字体册来安装
参考:https://support.apple.com/zh-cn/guide/font-book/fntbk1000/10.0/mac/10.15
windows
可参考:https://www.cnblogs.com/kuxingseng95/p/10021788.html
# 用下面代码找到Matplotlib的配置文件
import matplotlib
print(matplotlib.matplotlib_fname())