mpl_toolkits.axisartist.axis_artist.LabelBase#
- class mpl_toolkits.axisartist.axis_artist.LabelBase(*args, **kwargs)[源代码][源代码]#
基类:
TextAxisLabel和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) 数组和两个从图像左下角开始的偏移量
标量或无
布尔
布尔
带有
patches.FancyBboxPatch属性的字典未知
未知
未知
颜色或 cfontfamily或 family 或 fontname{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
fontproperties或 font 或 font_propertiesfontsize或 sizefloat 或 {'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之间, '超轻', '轻', '正常', '常规', '书', '中等', '罗马', '半粗', '半粗', '半', '粗', '重', '特粗', '黑'}
str
horizontalalignment或 ha{'left', 'center', 'right'}
布尔
对象
浮动(字体大小的倍数)
str
布尔
multialignment或 ma{'left', 'right', 'center'}
布尔
None 或 bool 或 float 或 callable
(浮点数, 浮点数)
布尔
浮点数或 {'垂直', '水平'}
{None, 'default', 'anchor'}
(scale: float, length: float, randomness: float)
布尔值或无
对象
布尔
str
bool, 默认值:
rcParams["text.usetex"](default:False)垂直对齐或 va{'baseline', 'bottom', 'center', 'center_baseline', 'top'}
布尔
布尔
浮动
浮动
浮动
- draw(renderer)[源代码][源代码]#
使用给定的渲染器绘制艺术家(及其子项)。
如果艺术家不可见(
Artist.get_visible返回 False),则此操作无效。- 参数:
- 渲染器 :
RendererBase子类。RendererBase 子类。
- 渲染器 :
注释
此方法在 Artist 子类中被重写。
- get_window_extent(renderer=None)[源代码][源代码]#
返回包围文本的
Bbox边界框,以显示单位表示。除了内部使用外,这对于在网页上的 png 文件中指定可点击区域也很有用。
- 参数:
- 渲染器渲染器,可选
需要一个渲染器来计算边界框。如果艺术家已经被绘制,渲染器会被缓存;因此,只有在第一次绘制前调用
get_window_extent时才需要传递此参数。实际上,通常更容易先触发一次绘制,例如通过调用draw_without_rendering或plt.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>)[源代码]#
一次性设置多个属性。
支持的属性有
属性
描述
一个过滤函数,它接收一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组和两个从图像左下角开始的偏移量
标量或无
布尔
布尔
带有
patches.FancyBboxPatch属性的字典BboxBase或 None布尔
补丁或(路径,变换)或无
颜色或 cfontfamily或 family 或 fontname{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
fontproperties或 font 或 font_propertiesfontsize或 sizefloat 或 {'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之间, '超轻', '轻', '正常', '常规', '书', '中等', '罗马', '半粗', '半粗', '半', '粗', '重', '特粗', '黑'}
str
horizontalalignment或 ha{'left', 'center', 'right'}
布尔
对象
浮动(字体大小的倍数)
str
布尔
multialignment或 ma{'left', 'right', 'center'}
布尔
None 或 bool 或 float 或 callable
(浮点数, 浮点数)
布尔
浮点数或 {'垂直', '水平'}
{None, 'default', 'anchor'}
(scale: float, length: float, randomness: float)
布尔值或无
对象
布尔
str
bool, 默认值:
rcParams["text.usetex"](default:False)垂直对齐或 va{'baseline', 'bottom', 'center', 'center_baseline', 'top'}
布尔
布尔
浮动
浮动
浮动