matplotlib图标中文显示

来源:互联网 发布:什么是数据透视表 编辑:程序博客网 时间:2024/05/22 02:30

设置有fontproperties属性的,还有prop属性的

1,找到系统已安装的字体

2,

from matplotlib.font_manager import FontProperties
#fname=r"(本地中文字体的路径位置)",size=设置字体大小
font = FontProperties(fname=r"C:\\Windows\\Fonts\\STKAITI.TTF", size=14)

3,

plt.xlabel('性别', fontproperties=font)

plt.ylabel('人数', fontproperties=font)

或则没有fontproperties属性的

plt.legend((rect,), ('图例',), prop=font)

然后设置的这些都可以正常的显示了


0 0