mpl_toolkits.axisartist.axis_artist.LabelBase#
- class mpl_toolkits.axisartist.axis_artist.LabelBase(*args, **kwargs)[源]#
基类:
Text
AxisLabel 和 TickLabels 的基类。文本的位置和角度通过 offset_ref_angle、text_ref_angle 和 offset_radius 属性计算。
在 x, y 位置创建一个值为 text 字符串的
Text
实例。文本相对于锚点 (x, y) 根据
horizontalalignment
(默认值:'left')和verticalalignment
(默认值:'baseline')进行对齐。另请参阅 文本对齐。虽然 Text 接受 'label' 关键字参数,但默认情况下它不会添加到图例的句柄中。
有效的关键字参数有:
属性
描述
一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量
浮点数或 None
布尔值
布尔值
带有
patches.FancyBboxPatch
属性的字典未知
未知
未知
fontfamily
或family
或fontname
{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
float 或 {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
{0-1000 范围内的数值, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}
{'normal', 'italic', 'oblique'}
{'normal', 'small-caps'}
{0-1000 范围内的数值, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}
字符串
{'left', 'center', 'right'}
布尔值
对象
float (字体大小的倍数)
字符串
布尔值
{'left', 'right', 'center'}
布尔值
None 或 布尔值 或 浮点数 或 可调用对象
(浮点数, 浮点数)
布尔值
float 或 {'vertical', 'horizontal'}
{None, 'default', 'anchor'}
(scale: 浮点数, length: 浮点数, randomness: 浮点数)
布尔值或 None
对象
布尔值
字符串
布尔值,默认值:
rcParams["text.usetex"]
(默认值:False
){'baseline', 'bottom', 'center', 'center_baseline', 'top'}
布尔值
布尔值
浮点数
浮点数
浮点数
- draw(renderer)[源]#
使用给定的渲染器绘制 Artist(及其子对象)。
如果 artist 不可见(
Artist.get_visible
返回 False),则此操作无效。- 参数:
- 渲染器
RendererBase
子类。
- 渲染器
备注
此方法在 Artist 子类中被覆盖。
- get_window_extent(renderer=None)[源]#
返回文本的边界框
Bbox
>,以显示单位表示。除了内部使用外,这对于在网页上的 png 文件中指定可点击区域也很有用。
- 参数:
- renderer渲染器,可选
需要一个渲染器来计算边界框。如果 artist 已经被绘制,渲染器会被缓存;因此,只有在第一次绘制之前调用
get_window_extent
时才需要传递此参数。实际上,通常更容易先触发绘制,例如通过调用draw_without_rendering
或plt.show()
。- dpifloat, 可选
用于计算边界框的 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>)[源]#
一次性设置多个属性。
支持的属性包括:
属性
描述
一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量
浮点数或 None
布尔值
布尔值
带有
patches.FancyBboxPatch
属性的字典BboxBase
或 None布尔值
Patch 或 (Path, Transform) 或 None
fontfamily
或family
或fontname
{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
float 或 {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
{0-1000 范围内的数值, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}
{'normal', 'italic', 'oblique'}
{'normal', 'small-caps'}
{0-1000 范围内的数值, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}
字符串
{'left', 'center', 'right'}
布尔值
对象
float (字体大小的倍数)
字符串
布尔值
{'left', 'right', 'center'}
布尔值
None 或 布尔值 或 浮点数 或 可调用对象
(浮点数, 浮点数)
布尔值
float 或 {'vertical', 'horizontal'}
{None, 'default', 'anchor'}
(scale: 浮点数, length: 浮点数, randomness: 浮点数)
布尔值或 None
对象
布尔值
字符串
布尔值,默认值:
rcParams["text.usetex"]
(默认值:False
){'baseline', 'bottom', 'center', 'center_baseline', 'top'}
布尔值
布尔值
浮点数
浮点数
浮点数