matplotlib.pyplot.axes#

matplotlib.pyplot.axes(arg=None, **kwargs)[source]#

将一个 Axes 添加到当前图形并使其成为当前 Axes。

调用签名

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

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

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

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

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

Axes 的投影类型。str 是自定义投影的名称,请参见 projections。默认 None 将生成 'rectilinear' 投影。

polarbool, 默认值: False

如果为 True,相当于 projection='polar'。

sharex, shareyAxes,可选

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

label字符串

返回的 Axes 的标签。

返回:
Axes,或 Axes 的子类

返回的 Axes 类取决于所使用的投影。如果使用直线投影,它就是 Axes;如果使用极坐标投影,它就是 projections.polar.PolarAxes

其他参数:
**kwargs

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

属性

描述

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

facecolor or fc

color

figure

Figure or SubFigure

forward_navigation_events

bool 或 "auto"

frame_on

布尔值

gid

字符串

in_layout

布尔值

label

object

mouseover

布尔值

navigate

布尔值

navigate_mode

未知

path_effects

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

字符串

transform

变换

url

字符串

visible

布尔值

xbound

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

xlabel

字符串

xlim

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

xmargin

float 大于 -0.5

xscale

未知

xticklabels

未知

xticks

未知

ybound

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

ylabel

字符串

ylim

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

ymargin

float 大于 -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 的示例#

子图间距和边距

子图间距和边距