ubuntu plt 中文乱码解决

1、首先在命令行输入

  fc-list :lang=zh 

2、选择一种支持中文的字体

/usr/share/fonts/truetype/arphic/uming.ttc

3、在代码中改变

import matplotlib as  mpl
zhfont = mpl.font_manager.FontProperties(fname='/usr/share/fonts/opentype/noto/NotoSansCJK-Light.ttc')
plt.xlabel(u'年龄',fontproperties = zhfont)
plt.ylabel(u'视力',fontproperties = zhfont)

你可能感兴趣的:(ubuntu plt 中文乱码解决)