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) 数组以及图像左下角的两个偏移量
浮点数或 None
布尔值
布尔值
包含
FancyBboxPatch属性的字典,或为 None未知
未知
未知
fontfamily或family或fontname{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
字符串列表、字符串元组或 None
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'}
str
{'left', 'center', 'right'}
布尔值
object
str 或 None
'normal' 或浮点数,默认:'normal'
str
布尔值
{'left', 'right', 'center'}
布尔值
None 或 布尔值 或 浮点数 或 可调用对象
(浮点数, 浮点数)
布尔值
float 或 {'vertical', 'horizontal'}
{None, 'default', 'anchor', 'xtick', 'ytick'}
(scale: 浮点数, length: 浮点数, randomness: 浮点数)
布尔值或 None
object
布尔值
str
布尔值,默认值:
rcParams["text.usetex"](默认:False){'baseline', 'bottom', 'center', 'center_baseline', 'top'}
布尔值
布尔值
浮点数
浮点数
浮点数
- draw(renderer)[源代码]#
使用给定的渲染器绘制 Artist(及其子对象)。
如果该艺术家对象不可见(
Artist.get_visible返回 False),则此操作无效。- 参数:
- renderer
RendererBase子类。
- renderer
备注
此方法在 Artist 子类中被覆盖。
- get_window_extent(renderer=None)[源代码]#
返回以显示单位表示的、包围文本的
Bbox。除了内部使用外,这对于在网页上的 png 文件中指定可点击区域也很有用。
- 参数:
- renderer渲染器,可选
计算边界框需要渲染器。如果艺术家(Artist)已经被绘制,渲染器会被缓存;因此,只有在第一次绘制之前调用
get_window_extent时才需要传递此参数。实际上,通常更简单的方法是先触发绘制,例如调用draw_without_rendering或plt.show()。- dpifloat, 可选
计算 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>, fontfeatures=<UNSET>, fontproperties=<UNSET>, fontsize=<UNSET>, fontstretch=<UNSET>, fontstyle=<UNSET>, fontvariant=<UNSET>, fontweight=<UNSET>, gid=<UNSET>, horizontalalignment=<UNSET>, in_layout=<UNSET>, label=<UNSET>, language=<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>)[源代码]#
一次性设置多个属性。
a.set(a=A, b=B, c=C)
等同于
a.set_a(A) a.set_b(B) a.set_c(C)
除全名属性外,还支持别名,例如
set(lw=2)等同于set(linewidth=2),但同时传入两者会报错。各个 setter 的调用顺序与
set()中的参数顺序一致。然而,大多数属性并不相互依赖,因此顺序通常无关紧要。支持的属性包括:
属性
描述
一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量
浮点数或 None
布尔值
布尔值
包含
FancyBboxPatch属性的字典,或为 NoneBboxBase或 None布尔值
Patch 或 (Path, Transform) 或 None
fontfamily或family或fontname{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
字符串列表、字符串元组或 None
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'}
str
{'left', 'center', 'right'}
布尔值
object
str 或 None
'normal' 或浮点数,默认:'normal'
str
布尔值
{'left', 'right', 'center'}
布尔值
None 或 布尔值 或 浮点数 或 可调用对象
(浮点数, 浮点数)
布尔值
float 或 {'vertical', 'horizontal'}
{None, 'default', 'anchor', 'xtick', 'ytick'}
(scale: 浮点数, length: 浮点数, randomness: 浮点数)
布尔值或 None
object
布尔值
str
布尔值,默认值:
rcParams["text.usetex"](默认:False){'baseline', 'bottom', 'center', 'center_baseline', 'top'}
布尔值
布尔值
浮点数
浮点数
浮点数