##安装matplotlib
pip install matlibplot --user
##可以看到pip安装的matplotlib没有中文字体
cd ~/.local/lib/python3.7/site-packages/matplotlib/mpl-data/
ls fonts/ttf
##给matplotlib添加中文字体,不建议直接复制到~/.local/lib/python3.7/site-packages/matplotlib/mpl-data/fonts/里
mkdir ~/.config/matplotlib
cd ~/.config/matplotlib
cp ~/.local/lib/python3.7/site-packages/matplotlib/mpl-data/matplotlibrc ./
mkdir fonts
##查找系统里ttf或otf格式的中文字体
fc-list :lang=zh | grep -e ttf -e otf
cp /usr/share/fonts/SourceHan/SourceHanSansCN-Normal.otf fonts
##最后打开~/.config/matplotlib/matplotlibrc,找到font.sans-serif 这一行,取消注释,删掉:后面的所有字体,再加上Source Han Sans CN就可以了