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(及其子对象)。

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

参数:
rendererRendererBase 子类。

备注

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

get_ref_artist()[源代码]#

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

get_texts_widths_heights_descents(renderer)[源代码]#

返回刻度标签的 (width, height, descent) 元组列表。

空标签将被省略。

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

浮点数或 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

object

linespacing

float (字体大小的倍数)

locs_angles_labels

未知

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

object

transform

变换

transform_rotates_text

布尔值

url

str

usetex

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

verticalalignmentva

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

visible

布尔值

wrap

布尔值

x

浮点数

y

浮点数

zorder

浮点数

set_axis_direction(label_direction)[源代码]#

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

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

属性

刻度标签角度

90

0

-90

180

刻度标签垂直对齐

居中

基线

居中

基线

刻度标签水平对齐

居中

居中

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

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