1.下载SimHei字体
Windows中将字体复制到C:\Windows\Fonts文件夹下。
Linux中将字体复制到/usr/share/fonts/ 文件夹下。
2.删除matplotlib缓存
进入python环境中,执行:
import matplotlib as mpl
mpl.get_cachedir()

删除该文件夹中的所有文件。
3.修改matplotlib配置
在python环境中执行:
import matplotlib as mpl
mpl.matplotlib_fname()
然后在matplotlibrc文件中加入:
font.family : sans-serif
font.sans-serif : SimHei
axes.unicode_minus : False
本文介绍如何在Windows和Linux系统下安装SimHei字体,并提供了清除matplotlib缓存及配置字体显示的方法,确保图表中文显示无误。
579

被折叠的 条评论
为什么被折叠?



