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
值
学员评价