matplotlib.pyplot.axvspan#

matplotlib.pyplot.axvspan(xmin, xmax, ymin=0, ymax=1, **kwargs)[源代码][源代码]#

在Axes上添加一个垂直跨度(矩形)。

矩形从 xminxmax 水平延伸,默认情况下,垂直延伸整个 y 轴。y 轴的延伸范围可以通过 *ymin*(默认值:0)和 *ymax*(默认值:1)来设置,这些值以轴单位表示;例如,ymin = 0.5 总是指 y 轴的中点,无论 set_ylim 设置的限制如何。

参数:
xmin浮动

跨度的x坐标下限,以数据单位表示。

xmax浮动

跨度的上x坐标,以数据单位表示。

yminfloat, 默认值: 0

跨度的较低 y 坐标,以 y 轴单位表示(0-1)。

ymaxfloat, 默认值: 1

跨度的上y坐标,以y轴单位表示(0-1)。

返回:
Rectangle

从 (xmin, ymin) 到 (xmax, ymax) 的垂直跨度(矩形)。

其他参数:
**kwargs : Rectangle 属性矩形属性

属性

描述

agg_filter

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

alpha

标量或无

角度

未知

animated

布尔

抗锯齿 或 aa

布尔值或无

bounds

(左,底,宽,高)

capstyle

CapStyle 或 {'butt', 'projecting', 'round'}

clip_box

BboxBase 或 None

clip_on

布尔

clip_path

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

颜色

color

edgecolor 或 ec

color or None

facecolor 或 fc

color or None

figure

FigureSubFigure

填充

布尔

gid

str

hatch

{'/', '', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

高度

未知

in_layout

布尔

joinstyle

JoinStyle 或 {'miter', 'round', 'bevel'}

标签

对象

线型 或 ls

{'-', '--', '-.', ':', '', (偏移, 开-关-序列), ...}

linewidth 或 lw

浮点数或无

鼠标悬停

布尔

path_effects

AbstractPathEffect 的列表

picker

None 或 bool 或 float 或 callable

光栅化

布尔

sketch_params

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

snap

布尔值或无

transform

Transform

url

str

可见

布尔

宽度

未知

x

未知

xy

(浮点数, 浮点数)

y

未知

zorder

浮动

参见

axhspan

在Axes上添加一个水平跨度。

注释

备注

这是 axes.Axes.axvspanpyplot 包装器

示例

绘制一个从 x = 1.25 到 x = 1.55 的垂直、绿色、半透明矩形,该矩形跨越 Axes 的 y 范围。

>>> axvspan(1.25, 1.55, facecolor='g', alpha=0.5)

使用 matplotlib.pyplot.axvspan 的示例#

绘制跨越一个轴的区域

Draw regions that span an Axes