首先需要安装字体,将https://github.com/tracyone/program_font中下载,将下载后的字体,放在/usr/share/fonts/下面
使用fc-list :lang=zh查看有那些字体可以使用
想下载字体的话,windows和ubuntu是共用的?
ttf,ttc后缀的都可以?
将下载好的字体放在/usr/share/fonts/下,可能需要修改权限
sudo chmod 777 fonts
也可以使用sudo cp simsun.ttf /usr/share/fonts/truetype/simsun.ttf将字体复制到fonts文件下
from matplotlib.font_manager import FontProperties
from pylab import *
sfont = FontProperties(fname='simsun.ttf')
tfont = FontProperties(fname='Time NewRoman.ttf')
maplotlib.rcParams['axes.unicode_minus'] = False
plt.xlabel(u'刘烨',fontproperties=sfont,fontsize=13)
plt.legend(pro=tfont)
现在就可以了