mpl_toolkits.axisartist.axis_artist.LabelBase#

class mpl_toolkits.axisartist.axis_artist.LabelBase(*args, **kwargs)[源代码][源代码]#

基类:Text

AxisLabelTickLabels 的基类。文本的位置和角度由 offset_ref_angle、text_ref_angle 和 offset_radius 属性计算。

x, y 位置创建一个带有字符串 textText 实例。

文本相对于锚点 (x, y) 根据 ``horizontalalignment``(默认:'left')和 ``verticalalignment``(默认:'baseline')进行对齐。另请参阅 文本对齐

虽然 Text 接受 'label' 关键字参数,但默认情况下它不会添加到图例的句柄中。

有效的关键字参数是:

属性

描述

agg_filter

一个过滤函数,它接收一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组和两个从图像左下角开始的偏移量

alpha

标量或无

animated

布尔

抗锯齿

布尔

背景颜色

color

bbox

带有 patches.FancyBboxPatch 属性的字典

clip_box

未知

clip_on

未知

clip_path

未知

颜色 或 c

color

figure

FigureSubFigure

fontfamily 或 family 或 fontname

{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}

fontproperties 或 font 或 font_properties

font_manager.FontPropertiesstrpathlib.Path

fontsize 或 size

float 或 {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}

fontstretch 或 stretch

{一个数值范围在0-1000,'超压缩','额外压缩','压缩','半压缩','正常','半扩展','扩展','额外扩展','超扩展'}

fontstyle 或样式

{'normal', 'italic', 'oblique'}

fontvariant 或 variant

{'normal', 'small-caps'}

fontweight 或 weight

{一个数值范围在0-1000之间, '超轻', '轻', '正常', '常规', '书', '中等', '罗马', '半粗', '半粗', '半', '粗', '重', '特粗', '黑'}

gid

str

horizontalalignment 或 ha

{'left', 'center', 'right'}

in_layout

布尔

标签

对象

行间距

浮动(字体大小的倍数)

math_fontfamily

str

鼠标悬停

布尔

multialignment 或 ma

{'left', 'right', 'center'}

parse_math

布尔

path_effects

AbstractPathEffect 列表

picker

None 或 bool 或 float 或 callable

位置

(浮点数, 浮点数)

光栅化

布尔

旋转

浮点数或 {'垂直', '水平'}

rotation_mode

{None, 'default', 'anchor'}

sketch_params

(scale: float, length: float, randomness: float)

snap

布尔值或无

文本

对象

transform

Transform

transform_rotates_text

布尔

url

str

usetex

bool, 默认值: rcParams["text.usetex"] (default: False)

垂直对齐 或 va

{'baseline', 'bottom', 'center', 'center_baseline', 'top'}

可见

布尔

wrap

布尔

x

浮动

y

浮动

zorder

浮动

draw(renderer)[源代码][源代码]#

使用给定的渲染器绘制艺术家(及其子项)。

如果艺术家不可见(Artist.get_visible 返回 False),则此操作无效。

参数:
渲染器 : RendererBase 子类。RendererBase 子类。

注释

此方法在 Artist 子类中被重写。

get_window_extent(renderer=None)[源代码][源代码]#

返回包围文本的 Bbox 边界框,以显示单位表示。

除了内部使用外,这对于在网页上的 png 文件中指定可点击区域也很有用。

参数:
渲染器渲染器,可选

需要一个渲染器来计算边界框。如果艺术家已经被绘制,渲染器会被缓存;因此,只有在第一次绘制前调用 get_window_extent 时才需要传递此参数。实际上,通常更容易先触发一次绘制,例如通过调用 draw_without_renderingplt.show()

dpi浮点数, 可选

用于计算 bbox 的 dpi 值,默认为 self.get_figure(root=True).dpi*不是*渲染器的 dpi);如果需要匹配保存为自定义 dpi 值的图像区域,则应设置此值。

set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, backgroundcolor=<UNSET>, bbox=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, fontfamily=<UNSET>, fontproperties=<UNSET>, fontsize=<UNSET>, fontstretch=<UNSET>, fontstyle=<UNSET>, fontvariant=<UNSET>, fontweight=<UNSET>, gid=<UNSET>, horizontalalignment=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linespacing=<UNSET>, math_fontfamily=<UNSET>, mouseover=<UNSET>, multialignment=<UNSET>, parse_math=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, rasterized=<UNSET>, rotation=<UNSET>, rotation_mode=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, text=<UNSET>, transform=<UNSET>, transform_rotates_text=<UNSET>, url=<UNSET>, usetex=<UNSET>, verticalalignment=<UNSET>, visible=<UNSET>, wrap=<UNSET>, x=<UNSET>, y=<UNSET>, zorder=<UNSET>)[源代码]#

一次性设置多个属性。

支持的属性有

属性

描述

agg_filter

一个过滤函数,它接收一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组和两个从图像左下角开始的偏移量

alpha

标量或无

animated

布尔

抗锯齿

布尔

背景颜色

color

bbox

带有 patches.FancyBboxPatch 属性的字典

clip_box

BboxBase 或 None

clip_on

布尔

clip_path

补丁或(路径,变换)或无

颜色 或 c

color

figure

FigureSubFigure

fontfamily 或 family 或 fontname

{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}

fontproperties 或 font 或 font_properties

font_manager.FontPropertiesstrpathlib.Path

fontsize 或 size

float 或 {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}

fontstretch 或 stretch

{一个数值范围在0-1000,'超压缩','额外压缩','压缩','半压缩','正常','半扩展','扩展','额外扩展','超扩展'}

fontstyle 或样式

{'normal', 'italic', 'oblique'}

fontvariant 或 variant

{'normal', 'small-caps'}

fontweight 或 weight

{一个数值范围在0-1000之间, '超轻', '轻', '正常', '常规', '书', '中等', '罗马', '半粗', '半粗', '半', '粗', '重', '特粗', '黑'}

gid

str

horizontalalignment 或 ha

{'left', 'center', 'right'}

in_layout

布尔

标签

对象

行间距

浮动(字体大小的倍数)

math_fontfamily

str

鼠标悬停

布尔

multialignment 或 ma

{'left', 'right', 'center'}

parse_math

布尔

path_effects

AbstractPathEffect 列表

picker

None 或 bool 或 float 或 callable

位置

(浮点数, 浮点数)

光栅化

布尔

旋转

浮点数或 {'垂直', '水平'}

rotation_mode

{None, 'default', 'anchor'}

sketch_params

(scale: float, length: float, randomness: float)

snap

布尔值或无

文本

对象

transform

Transform

transform_rotates_text

布尔

url

str

usetex

bool, 默认值: rcParams["text.usetex"] (default: False)

垂直对齐 或 va

{'baseline', 'bottom', 'center', 'center_baseline', 'top'}

可见

布尔

wrap

布尔

x

浮动

y

浮动

zorder

浮动