matplotlib.axes.Axes#

class matplotlib.axes.Axes(fig, *args, facecolor=None, frameon=True, sharex=None, sharey=None, label='', xscale=None, yscale=None, box_aspect=None, forward_navigation_events='auto', **kwargs)[source]#

一个 Axes 对象封装了图中单个(子)图的所有元素。

它包含大多数(子)图元素:AxisTickLine2DTextPolygon 等,并设置坐标系。

与图中所有可见元素一样,Axes 是 Artist 的子类。

Axes 实例通过回调属性支持回调,该回调属性是一个 CallbackRegistry 实例。可以连接的事件是 'xlim_changed' 和 'ylim_changed',回调将使用 func(ax) 调用,其中 axAxes 实例。

注意

作为用户,您不直接实例化 Axes,而是使用 Axes 创建方法;例如,来自 pyplotFiguresubplotssubplot_mosaicFigure.add_axes

在图中构建一个 Axes。

参数:
figFigure

Axes 构建在 Figure fig 中。

*args

*args 可以是一个 (left, bottom, width, height) 矩形或一个 Bbox。这指定了 Axes 放置的矩形(在图形坐标中)。

*args 也可以由三个数字或一个三位数组成;在后一种情况下,这些数字被视为独立的数字。这些数字被解释为 (nrows, ncols, index)(nrows, ncols) 指定子图数组的大小,index 是正在创建的子图的基于 1 的索引。最后,*args 也可以直接是 SubplotSpec 实例。

sharex, shareyAxes,可选

x 轴或 y 轴与输入 Axes 中的 x 轴或 y 轴共享。请注意,无法取消共享轴。

frameonbool,默认值:True

Axes 框架是否可见。

box_aspectfloat,可选

为 Axes 框设置固定纵横比,即高宽比。详情请参见 set_box_aspect

forward_navigation_eventsbool 或 "auto",默认值:"auto"

控制平移/缩放事件是否传递给其下方的 Axes。"auto" 表示对于具有不可见补丁的轴为 True,否则为 False

**kwargs

其他可选关键字参数

属性

描述

adjustable

{'box', 'datalim'}

agg_filter

一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量

alpha

浮点数或 None

anchor

(float, float) 或 {'C', 'SW', 'S', 'SE', 'E', 'NE', ...}

animated

布尔值

aspect

{'auto', 'equal'} 或 float

autoscale_on

布尔值

autoscalex_on

未知

autoscaley_on

未知

axes_locator

Callable[[Axes, Renderer], Bbox]

axisbelow

布尔值 或 'line'

box_aspect

浮点数或 None

clip_box

BboxBase 或 None

clip_on

布尔值

clip_path

Patch 或 (Path, Transform) 或 None

facecolorfc

color

figure

FigureSubFigure

forward_navigation_events

bool 或 "auto"

frame_on

布尔值

gid

str

in_layout

布尔值

label

object

mouseover

布尔值

navigate

布尔值

navigate_mode

未知

path_effects

list of AbstractPathEffect

picker

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

position

[left, bottom, width, height] 或 Bbox

prop_cycle

Cycler

rasterization_zorder

浮点数或 None

rasterized

布尔值

sketch_params

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

snap

布尔值或 None

subplotspec

未知

title

str

transform

变换

url

str

visible

布尔值

xbound

(lower: float, upper: float)

xlabel

str

xlim

(left: float, right: float)

xmargin

float 大于 -0.5

xscale

未知

xticklabels

未知

xticks

未知

ybound

(lower: float, upper: float)

ylabel

str

ylim

(bottom: float, top: float)

ymargin

float 大于 -0.5

yscale

未知

yticklabels

未知

yticks

未知

zorder

浮点数

返回:
Axes

新的 Axes 对象。