Ubuntu Matplotlib 显示中文

查找中文字体

find /usr/share/fonts/ -name "*.ttc"

设置Matplotlib字体

from matplotlib.font_manager import FontProperties

font = FontProperties(fname=r"/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc") # 从上面随便选一个
plt.title("标题", fontproperties=font)
plt.xlabel("x轴标签", fontproperties=font)
plt.ylabel("y轴标签", fontproperties=font)
plt.show()

posted @ 2020-04-20 10:51  Raina_R  阅读(1114)  评论(0编辑  收藏  举报