python fontproperties_Python matplotlib字体管理器使用替代字体

我尝试在matplotlib中使用替代字体。

通过使用字体管理器,我可以让类似xlabel、ylabel或title之类的东西正常工作,但我不知道如何更改在线标签上的字体

我挑”磷酸盐.ttc“字体容易辨认。在import matplotlib.font_manager as fm

import matplotlib.pyplot as plt

def lineChart():

my_font = fm.FontProperties(fname='/Library/Fonts/Phosphate.ttc')

day = ('1','2','3')

line1 = (10,20,30)

line2 = (30,20,10)

fig, ax = plt.subplots()

ax.plot(day, line1, label='this goes to default font')

ax.plot(day, line2, label='this is default font too')

ax.legend(loc='upper center')

plt.title('title display correct', fontproperties=my_font)

plt.xlabel('xlabel display correct', fontproperties=my_font)

plt.ylabel('ylabel display correct', fontproperties=my_font)

plt.savefig("font_test.png")

if __name__ == '__main__':

lineChart()

889Iv.png

有没有办法全局设置替代字体?(不将其安装到matplotlib模块路径)

或者设置线条标签使用替代字体?在

操作系统:OSX

Python:3.6.4

matplotlib:2.1.1

谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值