pandas anaconda2 matplotlib 解决中文

2021-04-25  本文已影响0人  邵红晓

python

plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号

1、cd anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data
将C:\Windows\Fonts\simhei.ttf 上传到该目录
2、chmod +x simhei.ttf
3、修改配置 anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data\matplotlibrc
font.sans-serif : SimHei, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
新增SimHei
4、清除缓存 .rm -rf .cache/matplotlib
5、执行python代码ok

上一篇下一篇

猜你喜欢

热点阅读