Python绘图(matplotlib)调用本机系统的字体及使用方法

python之matplotlib使用系统字体

  1. 导包from matplotlib.font_manager import FontProperties
  2. 调用本机字体库设置字体font = FontProperties(fname=r"C:\Windows\Fonts\simhei.ttf", size=14)
  3. 其中,simhei.ttf是自己电脑中的字体,如何找到呢,在路径C:\Windows\Fonts的文件夹中,有如下字体,如下图在这里插入图片描述
    带有常规字样的字体,如上图红圈中的内容,可以点击属性,找到字体,如下图在这里插入图片描述
  4. 关于使用,绘图的时候,直接调用就好plt.xlabel("数量",FontProperties=font)
发布了12 篇原创文章 · 获赞 3 · 访问量 1495

猜你喜欢

转载自blog.csdn.net/xcjJenifer/article/details/104932475
今日推荐