matplotlib 3.5.1

Other ParametersParametersReturnsBackRef
fill_between(self, x, y1, y2=0, where=None, interpolate=False, step=None, *, data=None, **kwargs)

The curves are defined by the points (x, y1) and (x, y2). This creates one or multiple polygons describing the filled area.

You may exclude some horizontal sections from filling using where.

By default, the edges connect the given points directly. Use step if the filling should be a step function, i.e. constant in between x.

Other Parameters

data : indexable object, optional

If given, the following parameters also accept a string s , which is interpreted as data[s] (unless this raises an exception):

x, y1, y2, where

**kwargs :

All other keyword arguments are passed on to .PolyCollection . They control the .Polygon properties:

Properties: 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: array-like or scalar or None animated: bool antialiased or aa or antialiaseds: bool or list of bools array: array-like or None capstyle: .CapStyle or {'butt', 'projecting', 'round'} clim: (vmin: float, vmax: float) clip_box: .Bbox clip_on: bool clip_path: Patch or (Path, Transform) or None cmap: .Colormap or str or None color: color or list of rgba tuples edgecolor or ec or edgecolors: color or list of colors or 'face' facecolor or facecolors or fc: color or list of colors figure: .Figure gid: str hatch: {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} in_layout: bool joinstyle: .JoinStyle or {'miter', 'round', 'bevel'} label: object linestyle or dashes or linestyles or ls: str or tuple or list thereof linewidth or linewidths or lw: float or list of floats norm: .Normalize or None offset_transform: .Transform offsets: (N, 2) or (2,) array-like path_effects: .AbstractPathEffect paths: list of array-like picker: None or bool or float or callable pickradius: float rasterized: bool sizes: ndarray or None sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform: .Transform url: str urls: list of str or None verts: list of array-like verts_and_codes: unknown visible: bool zorder: float

Parameters

x : array (length N)

The x coordinates of the nodes defining the curves.

y1 : array (length N) or scalar

The y coordinates of the nodes defining the first curve.

y2 : array (length N) or scalar, default: 0

The y coordinates of the nodes defining the second curve.

where : array of bool (length N), optional

Define where to exclude some horizontal regions from being filled. The filled regions are defined by the coordinates x[where] . More precisely, fill between x[i] and x[i+1] if where[i] and where[i+1] . Note that this definition implies that an isolated True value between two False values in where will not result in filling. Both sides of the True position remain unfilled due to the adjacent False values.

interpolate : bool, default: False

This option is only relevant if where is used and the two curves are crossing each other.

Semantically, where is often used for y1 > y2 or similar. By default, the nodes of the polygon defining the filled region will only be placed at the positions in the x array. Such a polygon cannot describe the above semantics close to the intersection. The x-sections containing the intersection are simply clipped.

Setting interpolate to True will calculate the actual intersection point and extend the filled region up to this point.

step : {'pre', 'post', 'mid'}, optional

Define step if the filling should be a step function, i.e. constant in between x. The value determines where the step will occur:

  • 'pre': The y value is continued constantly to the left from every x position, i.e. the interval (x[i-1], x[i]] has the value y[i] .

  • 'post': The y value is continued constantly to the right from every x position, i.e. the interval [x[i], x[i+1]) has the value y[i] .

  • 'mid': Steps occur half-way between the x positions.

Returns

`.PolyCollection`

A .PolyCollection containing the plotted polygons.

Fill the area between two horizontal curves.

See Also

fill_between

Fill between two sets of y-values.

fill_betweenx

Fill between two sets of x-values.

Examples

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

matplotlib.axes._axes.Axes.fill_between scipy.signal._fir_filter_design.minimum_phase matplotlib.legend_handler.HandlerPolyCollection matplotlib.stackplot.stackplot scipy.spatial._qhull.HalfspaceIntersection matplotlib.pyplot.stackplot matplotlib.axes._axes.Axes._fill_between_x_or_y matplotlib.axes._axes.Axes.fill_betweenx

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /matplotlib/axes/_axes.py#5250
type: <class 'function'>
Commit: