matplotlib:font_manager模块FontProperties类的使用(字体属性)

【摘要】 FontProperties类概述
FontProperties类用于存储和操作字体的属性。matplotlib支持的字体属性基于W3C Cascading Style Sheet, Level 1 font specification,主要有以下6个:字体类别(family)、字体风格(style)、字体粗细(weight)、字体大小(size)、字体拉伸(stre…

FontProperties类概述

FontProperties类用于存储和操作字体的属性。matplotlib支持的字体属性基于W3C Cascading Style Sheet, Level 1 font specification,主要有以下6个:字体类别(family)、字体风格(style)、字体粗细(weight)、字体大小(size)、字体拉伸(stretch)和字体变体(variant)。
在这里插入图片描述

FontProperties类签名为:class matplotlib.font_manager.FontProperties(family=None, style=None, variant=None, weight=None, stretch=None, size=None, fname=None, math_fontfamily=None)

FontProperties类构造函数参数分为:其中字体的6种属性的初始取值均来自对应的rcParams参数。

  • family:字体类别。取值范围为{ 'sans-serif' , 'serif', 'cursive', 'fantasy', 'monospace'},默认值为'sans-serif'。每个取值都代表一类字体,在matplotlib中对应数据结构为字体列表,优先级按位置递减。每次在使用时,matplotlib会根据rcParams根据字体类别和优先级确定某字体。

    family 解释
    sans-serif 无衬线体
    serif 衬线体
    cursive 手写体
    fantasy 符号字体
    monospace 等宽字体
    © 版权声明
    THE END
喜欢就支持一下吧
点赞0 分享