You are reading an old version of the documentation (v3.1.3). For the latest version see
Version 3.1.3
Fork me on GitHub

Table of Contents


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

Add a horizontal span (rectangle) across the axis.

Draw a horizontal span (rectangle) from ymin to ymax. With the default values of xmin = 0 and xmax = 1, this always spans the xrange, regardless of the xlim settings, even if you change them, e.g., with the set_xlim() command. That is, the horizontal extent is in axes coords: 0=left, 0.5=middle, 1.0=right but the y location is in data coordinates.

ymin : float

Lower limit of the horizontal span in data units.

ymax : float

Upper limit of the horizontal span in data units.

xmin : float, optional, default: 0

Lower limit of the vertical span in axes (relative 0-1) units.

xmax : float, optional, default: 1

Upper limit of the vertical span in axes (relative 0-1) units.

Polygon : Polygon
Other Parameters:
**kwargs : Polygon properties.
Property Description
agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha float or None
animated bool
antialiased or aa unknown
capstyle {'butt', 'round', 'projecting'}
clip_box Bbox
clip_on bool
clip_path [(Path, Transform) | Patch | None]
color color
contains callable
edgecolor or ec color or None or 'auto'
facecolor or fc color or None
figure Figure
fill bool
gid str
hatch {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout bool
joinstyle {'miter', 'round', 'bevel'}
label object
linestyle or ls {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw float or None
path_effects AbstractPathEffect
picker None or bool or float or callable
rasterized bool or None
sketch_params (scale: float, length: float, randomness: float)
snap bool or None
transform Transform
url str
visible bool
zorder float

See also

Add a vertical span across the axes.

Examples using matplotlib.pyplot.axhspan