matplotlib.pyplot.axhspan#

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

在 Axes 上添加一个水平跨度(矩形)。

矩形垂直方向从 ymin 延伸到 ymax,默认情况下水平方向延伸整个 x 轴。x 轴的范围可以使用 xmin(默认值:0)和 xmax(默认值:1)来设置,它们以坐标轴单位表示;例如,xmin = 0.5 始终表示 x 轴的中间,无论 set_xlim 设置的限制如何。

参数:
ymin浮点型

区域的下部 y 坐标,以数据单位表示。

ymax浮点型

区域的上部 y 坐标,以数据单位表示。

xmin浮点数,默认值:0

区域的下部 x 坐标,以 x 轴 (0-1) 单位表示。

xmax浮点数,默认值:1

区域的上部 x 坐标,以 x 轴 (0-1) 单位表示。

返回:
矩形

从 (xmin, ymin) 到 (xmax, ymax) 的水平区域(矩形)。

其他参数:
**kwargsRectangle 属性

属性

描述

agg_filter

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

alpha

浮点数或 None

angle

未知

animated

布尔值

antialiasedaa

布尔值或 None

bounds

(左,下,宽,高)

capstyle

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

clip_box

BboxBase 或 None

clip_on

布尔值

clip_path

Patch 或 (Path, Transform) 或 None

color

color

edgecolorec

颜色 或 None

facecolorfc

颜色 或 None

figure

FigureSubFigure

fill

布尔值

gid

str

hatch

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

hatch_linewidth

未知

height

未知

in_layout

布尔值

joinstyle

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

label

object

linestylels

{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}

linewidthlw

浮点数或 None

mouseover

布尔值

path_effects

AbstractPathEffect 的列表

picker

None 或 布尔值 或 浮点数 或 可调用对象

rasterized

布尔值

sketch_params

(scale: 浮点数, length: 浮点数, randomness: 浮点数)

snap

布尔值或 None

transform

变换

url

str

visible

布尔值

width

未知

x

未知

xy

(浮点数, 浮点数)

y

未知

zorder

浮点数

另请参阅

axvspan

在坐标轴上添加一个垂直区域。

备注

注意

这是 pyplot 包装器,用于 axes.Axes.axhspan

使用 matplotlib.pyplot.axhspan 的示例#

绘制跨越坐标轴的区域

绘制跨越坐标轴的区域