matplotlib.figure.SubFigure.add_axes#

SubFigure.add_axes(*args, **kwargs)[源码]#

向图中添加一个Axes

调用签名

add_axes(rect, projection=None, polar=False, **kwargs)
add_axes(ax)
参数:
rect元组 (left, bottom, width, height)

Axes的尺寸(左、下、宽、高)。所有量都以图的宽度和高度的比例表示。

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

Axes的投影类型。str 是自定义投影的名称,详见projections。默认值为None会生成一个“直角坐标系”投影。

polarbool, 默认值: False

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

axes_class Axes 的子类类型,可选

将被实例化的axes.Axes子类。此参数与projectionpolar不兼容。详见axisartist获取示例。

sharex, shareyAxes,可选

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

labelstr

返回的 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

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

浮点数

备注

在极少数情况下,add_axes可能会在仅有一个参数的情况下被调用,即一个已在当前图中创建但不在图的Axes列表中的Axes实例。

示例

一些简单的例子

rect = l, b, w, h
fig = plt.figure()
fig.add_axes(rect)
fig.add_axes(rect, frameon=False, facecolor='g')
fig.add_axes(rect, polar=True)
ax = fig.add_axes(rect, projection='polar')
fig.delaxes(ax)
fig.add_axes(ax)