matplotlib.pyplot.step#

matplotlib.pyplot.step(x,y,*args,where='pre',data=None,**kwargs)[source]#

Make a step plot.

Call signatures:

step(x,y,[fmt],*,data=None,where='pre',**kwargs)step(x,y,[fmt],x2,y2,[fmt2],...,*,where='pre',**kwargs)

This is just a thin wrapper aroundplot which changes someformatting options. Most of the concepts and parameters of plot can beused here as well.

Note

This method uses a standard plot with a step drawstyle: Thexvalues are the reference positions and steps extend left/right/bothdirections depending onwhere.

For the common case where you know the values and edges of thesteps, usestairs instead.

Parameters:
xarray-like

1D sequence of x positions. It is assumed, but not checked, thatit is uniformly increasing.

yarray-like

1D sequence of y levels.

fmtstr, optional

A format string, e.g. 'g' for a green line. Seeplot for a moredetailed description.

Note: While full format strings are accepted, it is recommended toonly specify the color. Line styles are currently ignored (usethe keyword argumentlinestyle instead). Markers are acceptedand plotted on the given positions, however, this is a rarelyneeded feature for step plots.

where{'pre', 'post', 'mid'}, default: 'pre'

Define where the steps should be placed:

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

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

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

dataindexable object, optional

An object with labelled data. If given, provide the label names toplot inx andy.

**kwargs

Additional parameters are the same as those forplot.

Returns:
list ofLine2D

Objects representing the plotted data.

Notes

Note

This is thepyplot wrapper foraxes.Axes.step.

Examples usingmatplotlib.pyplot.step#

Stairs Demo

Stairs Demo

Step Demo

Step Demo