Skip to content

Commit 542a427

Browse files
committed
improve docstring of Axes.step
1 parent 407a460 commit 542a427

File tree

1 file changed

+56
-26
lines changed

1 file changed

+56
-26
lines changed

lib/matplotlib/axes/_axes.py

+56-26
Original file line numberDiff line numberDiff line change
@@ -1931,37 +1931,63 @@ def step(self, x, y, *args, **kwargs):
19311931
"""
19321932
Make a step plot.
19331933
1934+
Call signatures::
1935+
1936+
plot(x, y, [fmt], data=None, where='pre', **kwargs)
1937+
plot(x, y, [fmt], x2, y2, [fmt2], ..., where='pre', **kwargs)
1938+
1939+
This is just a thin wrapper around `.plot` which changes some
1940+
formatting options. Most of the concepts and parameters of plot can be
1941+
used here as well.
1942+
19341943
Parameters
19351944
----------
19361945
x : array_like
1937-
1-D sequence, and it is assumed, but not checked,
1938-
that it is uniformly increasing.
1946+
1-D sequence of x positions. It is assumed, but not checked, that
1947+
it is uniformly increasing.
19391948
19401949
y : array_like
1941-
1-D sequence.
1950+
1-D sequence of y levels.
1951+
1952+
fmt : str, optional
1953+
A format string, e.g. 'g' for a green line. See `.plot` for a more
1954+
detailed description.
1955+
1956+
Note: While full format strings are accepted, it is recommended to
1957+
only specify the color. Line styles are currently ignored (use
1958+
the keyword argument *linestyle* instead). Markers are accepted
1959+
and plotted on the given positions, however, this is a rarely
1960+
needed feature for step plots.
1961+
1962+
data : indexable object, optional
1963+
An object with labelled data. If given, provide the label names to
1964+
plot in x and y.
1965+
1966+
where : [ 'pre' | 'post' | 'mid' ], optional, default 'pre'
1967+
Define where the steps should be placed:
1968+
1969+
- 'pre': The y value is continued constantly to the left from
1970+
every *x* position, i.e. the interval ``(x[i-1], x[i]]`` has the
1971+
value ``y[i]``.
1972+
- 'post': The y value is continued constantly to the right from
1973+
every *x* position, i.e. the interval ``[x[i], x[i+1])`` has the
1974+
value ``y[i]``.
1975+
- 'mid': Steps occur in the half-way between the *x* positions.
19421976
19431977
Returns
19441978
-------
1945-
list
1946-
List of lines that were added.
1979+
lines
1980+
A list of `~.Line2D` objects that were added.
19471981
19481982
Other Parameters
19491983
----------------
1950-
where : [ 'pre' | 'post' | 'mid' ]
1951-
If 'pre' (the default), the interval from
1952-
``x[i]`` to ``x[i+1]`` has level ``y[i+1]``.
1953-
1954-
If 'post', that interval has level ``y[i]``.
1955-
1956-
If 'mid', the jumps in *y* occur half-way between the
1957-
*x*-values.
1984+
**kwargs
1985+
Additional parameters are the same as those for `.plot`.
19581986
19591987
Notes
19601988
-----
1961-
Additional parameters are the same as those for
1962-
:func:`~matplotlib.pyplot.plot`.
1989+
.. [notes section required to get data note injection right]
19631990
"""
1964-
19651991
where = kwargs.pop('where', 'pre')
19661992
if where not in ('pre', 'post', 'mid'):
19671993
raise ValueError("'where' argument to step must be "
@@ -4992,16 +5018,18 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
49925018
Setting *interpolate* to *True* will calculate the actual
49935019
interscection point and extend the filled region up to this point.
49945020
4995-
step : {'pre', 'post', 'mid'}, optional
5021+
step : [ 'pre' | 'post' | 'mid' ], optional
49965022
Define *step* if the filling should be a step function,
49975023
i.e. constant in between *x*. The value determines where the
49985024
step will occur:
49995025
50005026
- 'pre': The y value is continued constantly to the left from
5001-
every *x* position.
5027+
every *x* position, i.e. the interval ``(x[i-1], x[i]]`` has the
5028+
value ``y[i]``.
50025029
- 'post': The y value is continued constantly to the right from
5003-
every *x* position.
5004-
- 'mid': Steps occur in the middle between the *x* positions.
5030+
every *x* position, i.e. the interval ``[x[i], x[i+1])`` has the
5031+
value ``y[i]``.
5032+
- 'mid': Steps occur in the half-way between the *x* positions.
50055033
50065034
Other Parameters
50075035
----------------
@@ -5174,16 +5202,18 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
51745202
Setting *interpolate* to *True* will calculate the actual
51755203
interscection point and extend the filled region up to this point.
51765204
5177-
step : {'pre', 'post', 'mid'}, optional
5205+
step : [ 'pre', 'post', 'mid' ], optional
51785206
Define *step* if the filling should be a step function,
51795207
i.e. constant in between *y*. The value determines where the
51805208
step will occur:
51815209
5182-
- 'pre': The y value is continued constantly below every *y*
5183-
position.
5184-
- 'post': The y value is continued constantly above every *y*
5185-
position.
5186-
- 'mid': Steps occur in the middle between the *y* positions.
5210+
- 'pre': The y value is continued constantly to the left from
5211+
every *x* position, i.e. the interval ``(x[i-1], x[i]]`` has the
5212+
value ``y[i]``.
5213+
- 'post': The y value is continued constantly to the right from
5214+
every *x* position, i.e. the interval ``[x[i], x[i+1])`` has the
5215+
value ``y[i]``.
5216+
- 'mid': Steps occur in the half-way between the *x* positions.
51875217
51885218
Other Parameters
51895219
----------------

0 commit comments

Comments
 (0)