问题描述
中文字体显示错误
解决办法
将win10下的字体文件simhei.ttf拷贝到matplotlib的安装目录/.... /python3.8/site-packages/matplotlib/mpl-data/fonts/ttf/
修改/.... /python3.8/site-packages/matplotlib/mpl-data/matplotlibrc,取消三行的注释,第二行添加字体
font.family : sans-serif
font.sans-serif : DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif, simhei, simkai
axes.unicode_minus : False
代码中添加:[1、import matplotlib.pyplot as plt;2、plt.rcParams[‘font.sans-serif’] = [‘simhei’]]
注:记得删除.cache中的缓冲文件,方法为先cd 用户目录,然后 rm -rf .cache
参考网址:https://www.pythonheidong.com/blog/article/371814/c3698bcef75f20079a93/
https://www.zhihu.com/question/25404709/answer/724680410
https://www.jb51.net/article/150878.htm