Skip to content

Commit 311ae7f

Browse files
committed
improve docstring of Axes.step
1 parent c09f726 commit 311ae7f

File tree

1 file changed

+55
-25
lines changed

1 file changed

+55
-25
lines changed

lib/matplotlib/axes/_axes.py

+55-25
Original file line numberDiff line numberDiff line change
@@ -1930,37 +1930,63 @@ def step(self, x, y, *args, **kwargs):
19301930
"""
19311931
Make a step plot.
19321932
1933+
Call signatures::
1934+
1935+
plot(x, y, [fmt], *, data=None, where='pre', **kwargs)
1936+
plot(x, y, [fmt], x2, y2, [fmt2], ..., *, where='pre', **kwargs)
1937+
1938+
This is just a thin wrapper around `.plot` which changes some
1939+
formatting options. Most of the concepts and parameters of plot can be
1940+
used here as well.
1941+
19331942
Parameters
19341943
----------
19351944
x : array_like
1936-
1-D sequence, and it is assumed, but not checked,
1937-
that it is uniformly increasing.
1945+
1-D sequence of x positions. It is assumed, but not checked, that
1946+
it is uniformly increasing.
19381947
19391948
y : array_like
1940-
1-D sequence.
1949+
1-D sequence of y levels.
1950+
1951+
fmt : str, optional
1952+
A format string, e.g. 'g' for a green line. See `.plot` for a more
1953+
detailed description.
1954+
1955+
Note: While full format strings are accepted, it is recommended to
1956+
only specify the color. Line styles are currently ignored (use
1957+
the keyword argument *linestyle* instead). Markers are accepted
1958+
and plotted on the given positions, however, this is a rarely
1959+
needed feature for step plots.
1960+
1961+
data : indexable object, optional
1962+
An object with labelled data. If given, provide the label names to
1963+
plot in x and y.
1964+
1965+
where : {'pre', 'post', 'mid'}, optional, default 'pre'
1966+
Define where the steps should be placed:
1967+
1968+
- 'pre': The y value is continued constantly to the left from
1969+
every *x* position, i.e. the interval ``(x[i-1], x[i]]`` has the
1970+
value ``y[i]``.
1971+
- 'post': The y value is continued constantly to the right from
1972+
every *x* position, i.e. the interval ``[x[i], x[i+1])`` has the
1973+
value ``y[i]``.
1974+
- 'mid': Steps occur in the half-way between the *x* positions.
19411975
19421976
Returns
19431977
-------
1944-
list
1945-
List of lines that were added.
1978+
lines
1979+
A list of `.Line2D` objects representing the plotted data.
19461980
19471981
Other Parameters
19481982
----------------
1949-
where : [ 'pre' | 'post' | 'mid' ]
1950-
If 'pre' (the default), the interval from
1951-
``x[i]`` to ``x[i+1]`` has level ``y[i+1]``.
1952-
1953-
If 'post', that interval has level ``y[i]``.
1954-
1955-
If 'mid', the jumps in *y* occur half-way between the
1956-
*x*-values.
1983+
**kwargs
1984+
Additional parameters are the same as those for `.plot`.
19571985
19581986
Notes
19591987
-----
1960-
Additional parameters are the same as those for
1961-
:func:`~matplotlib.pyplot.plot`.
1988+
.. [notes section required to get data note injection right]
19621989
"""
1963-
19641990
where = kwargs.pop('where', 'pre')
19651991
if where not in ('pre', 'post', 'mid'):
19661992
raise ValueError("'where' argument to step must be "
@@ -4997,10 +5023,12 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
49975023
step will occur:
49985024
49995025
- 'pre': The y value is continued constantly to the left from
5000-
every *x* position.
5026+
every *x* position, i.e. the interval ``(x[i-1], x[i]]`` has the
5027+
value ``y[i]``.
50015028
- 'post': The y value is continued constantly to the right from
5002-
every *x* position.
5003-
- 'mid': Steps occur in the middle between the *x* positions.
5029+
every *x* position, i.e. the interval ``[x[i], x[i+1])`` has the
5030+
value ``y[i]``.
5031+
- 'mid': Steps occur in the half-way between the *x* positions.
50045032
50055033
Other Parameters
50065034
----------------
@@ -5173,16 +5201,18 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
51735201
Setting *interpolate* to *True* will calculate the actual
51745202
interscection point and extend the filled region up to this point.
51755203
5176-
step : {'pre', 'post', 'mid'}, optional
5204+
step : [ 'pre', 'post', 'mid' ], optional
51775205
Define *step* if the filling should be a step function,
51785206
i.e. constant in between *y*. The value determines where the
51795207
step will occur:
51805208
5181-
- 'pre': The y value is continued constantly below every *y*
5182-
position.
5183-
- 'post': The y value is continued constantly above every *y*
5184-
position.
5185-
- 'mid': Steps occur in the middle between the *y* positions.
5209+
- 'pre': The y value is continued constantly to the left from
5210+
every *x* position, i.e. the interval ``(x[i-1], x[i]]`` has the
5211+
value ``y[i]``.
5212+
- 'post': The y value is continued constantly to the right from
5213+
every *x* position, i.e. the interval ``[x[i], x[i+1])`` has the
5214+
value ``y[i]``.
5215+
- 'mid': Steps occur in the half-way between the *x* positions.
51865216
51875217
Other Parameters
51885218
----------------

0 commit comments

Comments
 (0)