原因:matplotlib中没有中文字体
环境:win7+python3.6
解决办法:
1.打开配置文件
import matplotlib
matplotlib.matplotlib_fname()
可以得到配置文件matplotlibrc地址

用文本编辑器打开配置文件
2.修改配置文件
将文件中的
#font.family: sans-serif
去掉注释,修改为
font.family: arial unicode ms
打开C:\Windows\Fonts文件夹,把arial unicode ms字体复制粘贴到配置文件matplotlibrc同目录下的Fonts文件夹中。
到C:\Users\用户名.matplotlib,把里面的缓存文件删除。
重启python即可显示为中文
本文详细介绍了在win7+python3.6环境下,解决matplotlib无法显示中文的问题。通过修改配置文件,添加中文字体,以及清除缓存,实现matplotlib中文正常显示。
1117

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



