mpl.pyplot.axvspan()¶
-
mpl.pyplot.axvspan(xmin, xmax, ymin=0, ymax=1, hold=None, **kwargs)[source]¶ 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.Polygoninstance.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
Polygonproperties:agg_filter: unknown alpha: float or None animated: [True | False] antialiased or aa: [True | False] or None for default axes: anAxesinstance capstyle: [‘butt’ | ‘round’ | ‘projecting’] clip_box: amatplotlib.transforms.Bboxinstance clip_on: [True | False] clip_path: [ (Path,Transform) |Patch| None ] color: matplotlib color spec contains: a callable function edgecolor or ec: mpl color spec, or None for default, or ‘none’ for no color facecolor or fc: mpl color spec, or None for default, or ‘none’ for no color figure: amatplotlib.figure.Figureinstance fill: [True | False] gid: an id string hatch: [‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’] joinstyle: [‘miter’ | ‘round’ | ‘bevel’] label: string or anything printable with ‘%s’ conversion. linestyle or ls: [‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) |'-'|'--'|'-.'|':'|'None'|' '|''] linewidth or lw: float or None for default path_effects: unknown picker: [None|float|boolean|callable] rasterized: [True | False | None] sketch_params: unknown snap: unknown transform:Transforminstance url: a url string visible: [True | False] zorder: any numberSee also
axhspan()- for example plot and source code
Additional kwargs: hold = [True|False] overrides default hold state