matplotlib.pyplot.axes#

matplotlib.pyplot.axes(arg=None, **kwargs)[源代码][源代码]#

在当前图形中添加一个轴,并使其成为当前轴。

调用签名:

plt.axes()
plt.axes(rect, projection=None, polar=False, **kwargs)
plt.axes(ax)
参数:
参数None 或 4-元组

此函数的具体行为取决于类型:

  • None:使用 subplot(**kwargs) 添加一个新的全窗口 Axes。

  • 4个浮点数的元组 rect = (left, bottom, width, height)。使用当前图形上的 add_axes 以标准化 (0, 1) 单位添加一个新 Axes,其尺寸为 rect

投影{None, 'aitoff', 'hammer', 'lambert', 'mollweide', 'polar', 'rectilinear', str}, 可选

Axes 的投影类型。str 是自定义投影的名称,参见 projections。默认的 None 结果是 'rectilinear' 投影。

极地bool, 默认: False

如果为真,等同于 projection='polar'。

sharex, sharey : Axes, 可选Axes, 可选

使用 sharex 和/或 sharey 共享 x 或 y axis。轴将具有与共享的 Axes 相同的限制、刻度和比例。

标签str

返回的 Axes 的标签。

返回:
Axes,或 Axes 的子类

返回的 Axes 类取决于所使用的投影。如果使用直角投影,则为 Axes;如果使用极坐标投影,则为 projections.polar.PolarAxes

其他参数:
**kwargs

此方法还接受返回的 Axes 类的关键字参数。直角坐标系 Axes 类的关键字参数 Axes 可以在下表中找到,但如果使用其他投影,可能还会有其他关键字参数,请参阅实际的 Axes 类。

属性

描述

可调整

{'box', 'datalim'}

agg_filter

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

alpha

标量或无

锚点

(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

浮点数或无

clip_box

BboxBase 或 None

clip_on

布尔

clip_path

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

facecolor 或 fc

color

figure

FigureSubFigure

forward_navigation_events

布尔值或“自动”

frame_on

布尔

gid

str

in_layout

布尔

标签

对象

鼠标悬停

布尔

导航

布尔

navigate_mode

未知

path_effects

AbstractPathEffect 列表

picker

None 或 bool 或 float 或 callable

位置

[左, 底, 宽, 高] 或 Bbox

prop_cycle

Cycler

rasterization_zorder

浮点数或无

光栅化

布尔

sketch_params

(scale: float, length: float, randomness: float)

snap

布尔值或无

subplotspec

未知

标题

str

transform

Transform

url

str

可见

布尔

xbound

(下限: 浮点数, 上限: 浮点数)

xlabel

str

xlim

(左: 浮点数, 右: 浮点数)

xmargin

浮点数大于 -0.5

xscale

未知

xticklabels

未知

xticks

未知

ybound

(下限: 浮点数, 上限: 浮点数)

ylabel

str

ylim

(底部: 浮点数, 顶部: 浮点数)

ymargin

浮点数大于 -0.5

yscale

未知

yticklabels

未知

yticks

未知

zorder

浮动

示例

# Creating a new full window Axes
plt.axes()

# Creating a new Axes with specified dimensions and a grey background
plt.axes((left, bottom, width, height), facecolor='grey')

使用 matplotlib.pyplot.axes 的示例#

子图间距和边距

Subplots spacings and margins