mpl_toolkits.axisartist.axis_artist.TickLabels#

class mpl_toolkits.axisartist.axis_artist.TickLabels(*, axis_direction='bottom', **kwargs)[源代码][源代码]#

基类:AxisLabel

刻度标签。虽然源自 Text,但这个单一的艺术家绘制了所有的刻度标签。与 AxisLabel 类似,文本的位置是动态更新的,因此改变文本位置没有效果。否则,属性可以像普通的 Text 一样更改。与 Matplotlib 主线中的刻度标签不同,单个刻度标签的属性无法单独修改。

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

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

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

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

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

注释

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

get_ref_artist()[源代码][源代码]#

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

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

返回一个包含 (宽度, 高度, 下降) 元组的列表,用于刻度标签。

空标签将被忽略。

get_window_extents(renderer=None)[源代码][源代码]#
invert_axis_direction()[源代码][源代码]#
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>, locs_angles_labels=<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

标量或无

animated

布尔值

抗锯齿

布尔值

axis_direction

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

backgroundcolor

color

bbox

带有 patches.FancyBboxPatch 属性的字典

clip_box

BboxBase 或 None

clip_on

布尔值

clip_path

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

颜色 或 c

color

默认对齐

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

默认角度

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

figure

FigureSubFigure

fontfamily 或 family 或 fontname

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

fontproperties 或 font 或 font_properties

font_manager.FontPropertiesstrpathlib.Path

字体大小 或大小

浮点数或 {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}

fontstretch 或 stretch

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

字体样式 或样式

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

fontvariant 或 variant

{'normal', 'small-caps'}

fontweight 或 weight

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

gid

str

horizontalalignment 或 ha

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

in_layout

布尔值

标签

对象

行间距

浮动(字体大小的倍数)

locs_angles_labels

未知

math_fontfamily

str

鼠标悬停

布尔值

多重对齐 或 ma

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

pad

浮动

解析数学

布尔值

path_effects

AbstractPathEffect 的列表

picker

None 或 bool 或 float 或 callable

位置

(浮点数, 浮点数)

光栅化

布尔值

旋转

float 或 {'vertical', 'horizontal'}

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

浮动

set_axis_direction(label_direction)[源代码][源代码]#

根据 Matplotlib 的约定调整刻度标签的文本角度和文本对齐方式。

label_direction 必须是 [left, right, bottom, top] 之一。

属性

底部

正确

顶部

ticklabel 角度

90

0

-90

180

ticklabel va

中心

基线

中心

基线

ticklabel ha

正确

中心

正确

中心

请注意,文本角度实际上是相对于(90 + 刻度标签方向的角度)的,这为底部轴提供了0度。

参数:
标签方向{"left", "bottom", "right", "top"}
set_locs_angles_labels(locs_angles_labels)[源代码][源代码]#