matplotlib

Travis-CI:

This Page

matplotlib.axes.Axes.axvspan

Axes.axvspan(xmin, xmax, ymin=0, ymax=1, **kwargs)

Add a vertical span (rectangle) across the axes.

Call signature:

axvspan(xmin, xmax, ymin=0, ymax=1, **kwargs)

x coords are in data units and y coords are in axes (relative 0-1) units.

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

Return value is the matplotlib.patches.Polygon instance.

Examples:

  • draw a vertical green translucent rectangle from x=1.25 to 1.55 that spans the yrange of the axes:

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

Valid kwargs are Polygon properties:

Property Description
agg_filter unknown
alpha float or None
animated [True | False]
antialiased or aa [True | False] or None for default
axes an Axes instance
bottom_margin unknown
capstyle [‘butt’ | ‘round’ | ‘projecting’]
clip_box a matplotlib.transforms.Bbox instance
clip_on [True | False]
clip_path [ (Path, Transform) | Patch | None ]
color matplotlib color spec
contains a callable function
edgecolor or ec mpl color spec, None, ‘none’, or ‘auto’
facecolor or fc mpl color spec, or None for default, or ‘none’ for no color
figure a matplotlib.figure.Figure instance
fill [True | False]
gid an id string
hatch [‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’]
joinstyle [‘miter’ | ‘round’ | ‘bevel’]
label string or anything printable with ‘%s’ conversion.
left_margin unknown
linestyle or ls [‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
linewidth or lw float or None for default
margins unknown
path_effects unknown
picker [None|float|boolean|callable]
rasterized [True | False | None]
right_margin unknown
sketch_params unknown
snap unknown
top_margin unknown
transform Transform instance
url a url string
visible [True | False]
zorder any number

See also

axhspan()
for example plot and source code