课程评价 (0)

请对课程作出评价:
0/300

学员评价

暂无精选评价
15分钟

Text类

matplotlib.text.Text类是绘制文字的类(基类是matplotlib.artist.Artist)。它的构造函数为:  Text(x=0, y=0, text='', color=None, verticalalignment='baseline',  horizontalalignment=’left’, multialignment=None, fontproperties =None, rotation=None, linespacing=None, rotation_  mode=None, usetex=None, wrap=False, **kwargs) 这些关键字参数也是属性。其属性有:

  • 继承自Artist基类的属性: .alpha.animated.axes.clip_box、..clip_on.clip_path.contains.figure.gid.label.picker.transform.url.visible.zorder
  • .backgroundcolor属性:背景色,可以为任何matplotlib color
  • .bbox属性:文本框的边框。其值是FancyBboxPatch类的属性字典。
  • .color属性:字体颜色,可以为任何matplotlib color
  • .family或者.name或者.fontfamily或者.fontname属性:字体的名字。可以是string或者string list(表示可以为若干个名字,优先级依次递减)。string必须是一个真实字体的名字,或者一个字体的class name
  • .fontproperties或者.font_properties属性:字体的属性,值是一个matplotlib.font_manager.FontProperties实例(该实例一次性设置字体的很多属性,比如字体类型、字体名字、字体大小、宽度、...)
  • .horizontalalignment或者.ha属性:水平对齐方式,可以为'center'、'right'、'left'
  • .linespacing属性:为浮点数,单位为font size,表示行间距
  • .multialignment属性:multiline text对齐方式,可以为'left'、'right'、'center'
  • .position属性:为一个元组(x,y),表示文本框的位置
  • .rotation属性:字体旋转角度。可以为下列值:
    • 浮点数,表示角度
    • 'vertical'、'horizontal'
  • .rotation_mode属性:旋转模式。可以为下列值:
    • 'anchor':文本首先对齐,然后根据对齐点来旋转
    • None:文本先旋转,再对齐
  • .size或者.fontsize属性:字体大小。可以为下列值:
    • 浮点值,表示字体大小
    • 'xx-small'、'x-small'、'small'、'medium'、'large'、'x-large'、'xx-large'
  • .stretch或者.fontstretch属性:字体沿水平方向的拉伸。可以为下列值:
    • 整数,在[0---1000]之间
    • 'ultra-condensed''extra-condensed''condensed''semi-condensed''normal''semi-expanded''expanded''extra-expanded''ultra-expanded'
  • .style或者.fontstyle属性:字体样式,可以为'normal'、'italic'、'oblique'
  • .text属性:文本字符串,可以为任意字符串(他可以包含'\n'换行符或者LATEX语法)
  • .variant或者.fontvariant属性:表示字体形变,可以为下列值:'normal'、'small-caps'
  • .verticalalignment或者.ma或者.va属性:表示文本的垂直对齐,可以为下列值:
    • 'center'、'top'、'bottom'、'baseline'
  • .weight或者.fontweight属性:设置字体的weight,可以为下列值:
    • 一个整数值,在[0---1000]之间
    • 'ultralight''light''normal''regular''book'、'medium''roman''semibold''demibold''demi''bold''heavy''extrabold''black'
  • .x属性:一个浮点值,表示文本框位置的x
  • .y属性:一个浮点值,表示文本框位置的y