mpl_toolkits.axisartist.axis_artist.AxisLabel#

class mpl_toolkits.axisartist.axis_artist.AxisLabel(*args, axis_direction='bottom', axis=None, **kwargs)[源码]#

基类:AttributeCopier, LabelBase

坐标轴标签。派生自 Text。文本位置会即时更新,因此更改文本位置无效。否则,属性可以像普通 Text 一样更改。

要更改刻度标签和坐标轴标签之间的填充,请使用 set_pad

draw(renderer)[源码]#

使用给定的渲染器绘制 Artist(及其子对象)。

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

参数:
rendererRendererBase 子类。

备注

此方法在 Artist 子类中被覆盖。

get_color()[源码]#

返回文本颜色。

get_pad()[源码]#

返回以点为单位的内部填充。

有关更多详细信息,请参阅 set_pad

get_ref_artist()[源码]#

返回实际定义此 artist 的某些属性(例如,颜色)的基础 artist。

get_text()[源码]#

返回文本字符串。

get_window_extent(renderer=None)[源码]#

返回以显示单位表示的、边界文本的 Bbox

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

参数:
renderer渲染器,可选

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

dpifloat, 可选

用于计算边界框的 DPI 值默认为 self.get_figure(root=True).dpi不是 渲染器 DPI);例如,如果需要匹配以自定义 DPI 值保存的图形区域,则应进行设置。

set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, axis_direction=<UNSET>, backgroundcolor=<UNSET>, bbox=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, default_alignment=<UNSET>, default_angle=<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>, pad=<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

浮点数或 None

animated

布尔值

antialiased

布尔值

axis_direction

{"left", "bottom", "right", "top"}

backgroundcolor

color

bbox

带有 patches.FancyBboxPatch 属性的字典

clip_box

BboxBase 或 None

clip_on

布尔值

clip_path

Patch 或 (Path, Transform) 或 None

colorc

color

default_alignment

{"left", "bottom", "right", "top"}

default_angle

{"left", "bottom", "right", "top"}

figure

FigureSubFigure

fontfamilyfamilyfontname

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

fontpropertiesfontfont_properties

font_manager.FontPropertiesstrpathlib.Path

fontsizesize

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

fontstretchstretch

{0-1000 范围内的数值, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}

fontstylestyle

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

fontvariantvariant

{'normal', 'small-caps'}

fontweightweight

{0-1000 范围内的数值, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}

gid

str

horizontalalignmentha

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

in_layout

布尔值

label

对象

linespacing

float (字体大小的倍数)

math_fontfamily

str

mouseover

布尔值

multialignmentma

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

pad

浮点数

parse_math

布尔值

path_effects

AbstractPathEffect 列表

picker

None 或 布尔值 或 浮点数 或 可调用对象

position

(浮点数, 浮点数)

rasterized

布尔值

rotation

float 或 {'vertical', 'horizontal'}

rotation_mode

{None, 'default', 'anchor'}

sketch_params

(scale: 浮点数, length: 浮点数, randomness: 浮点数)

snap

布尔值或 None

text

对象

transform

变换

transform_rotates_text

布尔值

url

str

usetex

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

verticalalignmentva

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

visible

布尔值

wrap

布尔值

x

浮点数

y

浮点数

zorder

浮点数

set_axis_direction(d)[源码]#

根据 matplotlib 惯例调整坐标轴标签的文本角度和文本对齐方式。

属性

轴标签角度

180

0

0

180

轴标签垂直对齐

居中

居中

轴标签水平对齐

居中

居中

请注意,文本角度实际上是相对于 (90 + 指向刻度标签的方向角度) 的,对于底部坐标轴,这会得到 0。

参数:
d{"left", "bottom", "right", "top"}
set_default_alignment(d)[源码]#

设置默认对齐方式。有关详细信息,请参阅 set_axis_direction

参数:
d{"left", "bottom", "right", "top"}
set_default_angle(d)[源码]#

设置默认角度。有关详细信息,请参阅 set_axis_direction

参数:
d{"left", "bottom", "right", "top"}
set_pad(pad)[源码]#

设置以点为单位的内部填充。

实际填充将是内部填充和外部填充之和(后者由 AxisArtist 自动设置)。

参数:
pad浮点数

以点为单位的内部填充。