2022-10-28 matplot标签无法显示中文 mac

第一步
进入python ,找到matplotlib所在路径

import matplotlib
matplotlib.matplotlib_fname()
第二步
编辑 matplotlibrc 文件

(1)找到 #font.family:sans-serif ,将前面的“#”删除

(2)找到 #font.sana-serif: DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva,

               Lucid, Arial, Helvetica, Avant Garde, sans-serif       

     在  “DejaVu Sans” 前面添加 “Arial Unicode MS, ”

(3)找到axes.unicode_minus 将其后面的“True” 改为“False”

第三步
将~/.matplotlib目录下的两个文件删除

在命令终端输入:

rm -rf ~/.matplotlib/*
重启python,即可解决中文及“-”无法正常显示的问题。

测试程序:

你可能感兴趣的:(2022-10-28 matplot标签无法显示中文 mac)