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, sharey
Axes
,可选 与 sharex 和/或 sharey 共享 x 轴或 y 轴。该轴将具有与共享 Axes 的轴相同的限制、刻度线和比例。
- label字符串
返回的 Axes 的标签。
- 返回:
Axes
,或Axes
的子类返回的 Axes 类取决于所使用的投影。如果使用直线投影,它就是
Axes
;如果使用极坐标投影,它就是projections.polar.PolarAxes
。
- 其他参数:
- **kwargs
此方法也接受返回的 Axes 类的关键字参数。直线 Axes 类
Axes
的关键字参数可在下表中找到,但如果使用其他投影,可能还会有其他关键字参数,请参阅实际的 Axes 类。属性
描述
{'box', 'datalim'}
一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量
浮点数或 None
(float, float) 或 {'C', 'SW', 'S', 'SE', 'E', 'NE', ...}
布尔值
{'auto', 'equal'} 或 float
布尔值
未知
未知
Callable[[Axes, Renderer], Bbox]
布尔值 或 'line'
浮点数或 None
BboxBase
或 None布尔值
Patch 或 (Path, Transform) 或 None
bool 或 "auto"
布尔值
字符串
布尔值
object
布尔值
布尔值
未知
None 或 布尔值 或 浮点数 或 可调用对象
[left, bottom, width, height] 或
Bbox
浮点数或 None
布尔值
(scale: 浮点数, length: 浮点数, randomness: 浮点数)
布尔值或 None
未知
字符串
字符串
布尔值
(下限: 浮点数, 上限: 浮点数)
字符串
(左: 浮点数, 右: 浮点数)
float 大于 -0.5
未知
未知
未知
(下限: 浮点数, 上限: 浮点数)
字符串
(下: 浮点数, 上: 浮点数)
float 大于 -0.5
未知
未知
未知
浮点数
示例
# 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')