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 around
plot
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, use
stairs
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. See
plot
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 for
plot
.
- Returns:
- list of
Line2D
Objects representing the plotted data.
- list of
Notes
Note
This is thepyplot wrapper for
axes.Axes.step
.