Mac系统下解决python中matplotlib画图不能显示中文标题的问题
下载SimHei字体并解压
添加字体
查看路径
import matplotlib
matplotlib.matplotlib_fname()
然后将输出的路径的matplotlibrc替换为fonts/ttf ,在这个文件中放入刚才下载的字体。
修改配置文件
使用vim打开matplotlibrc文件,输入i开始编辑
修改三个地方
font.family : sans-serif
# 去掉前面的#
font.sans-serif : SimHei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
# 去掉前面的#,添加SimHei
axes.unicode_minus : False
# 去掉前面的#,并将True改为False
按下esc推出编辑模式,按:wq保存并退出。
在shell中打开python,运行如下代码
from matplotlib.font_manager import _rebuild
_rebuild()

浙公网安备 33010602011771号