matplotlib.axes.Axes.axhspan#

Axes.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

布尔值

antialiased or aa

布尔值或 None

bounds

(左,下,宽,高)

capstyle

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

clip_box

BboxBase 或 None

clip_on

布尔值

clip_path

Patch 或 (Path, Transform) 或 None

color

color

edgecolor or ec

颜色 或 None

facecolor or fc

颜色 或 None

figure

Figure or SubFigure

fill

布尔值

gid

str

hatch

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

hatch_linewidth

未知

height

未知

in_layout

布尔值

joinstyle

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

label

object

linestyle or ls

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

linewidth or lw

浮点数或 None

mouseover

布尔值

path_effects

list of AbstractPathEffect

picker

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

rasterized

布尔值

sketch_params

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

snap

布尔值或 None

transform

变换

url

str

visible

布尔值

width

未知

x

未知

xy

(浮点数, 浮点数)

y

未知

zorder

浮点数

另请参阅

axvspan

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

使用 matplotlib.axes.Axes.axhspan 的示例#

带透明度的 fill_between

带透明度的 fill_between

绘制跨越坐标轴的区域

绘制跨越坐标轴的区域