解决Python matplotlib绘图画布上中文乱码问题
问题描述:
当用matplotlib库画图时,画布上的中文乱码(成为一个个空白格子)
如下示:
解决:
- 找到
matplotlibrc
配置文件,一般在python的依赖包安装的位置,比如我的在:F:/python3.8.3/lib/site-packages/matplotlib/mpl-data/matplotlibrc
- 找到
matplotlibrc
配置文件中的#font.family: sans-serif
这一行 - 在这一行的下面添加:
font.family: Microsoft YaHei
- 重启PyCharm,重新编译启动项目,就会正常显示为中文