Skip to content

Commit 82da01b

Browse files
committed
improve docstrings of Axes.fill_between, Axes.fill_betweenx
1 parent 2296775 commit 82da01b

File tree

1 file changed

+113
-69
lines changed

1 file changed

+113
-69
lines changed

lib/matplotlib/axes/_axes.py

+113-69
Original file line numberDiff line numberDiff line change
@@ -4742,64 +4742,86 @@ def fill(self, *args, **kwargs):
47424742
label_namer=None)
47434743
@docstring.dedent_interpd
47444744
def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
4745-
step=None,
4746-
**kwargs):
4745+
step=None, **kwargs):
47474746
"""
4748-
Make filled polygons between two curves.
4747+
Fill the area between two horizontal curves.
47494748
4749+
The curves are defined by the points (*x*, *y1*) and (*x*, *y2*). This
4750+
creates one or multiple polygons describing the filled area.
4751+
4752+
You may exclude some horizontal sections from filling using *where*.
4753+
4754+
By default, the edges connect the given points directly. Use *step* if
4755+
the filling should be a step function, i.e. constant in between *x*.
47504756
4751-
Create a :class:`~matplotlib.collections.PolyCollection`
4752-
filling the regions between *y1* and *y2* where
4753-
``where==True``
47544757
47554758
Parameters
47564759
----------
4757-
x : array
4758-
An N-length array of the x data
4760+
x : array (length N)
4761+
The x coordinates of the nodes defining the curves.
47594762
4760-
y1 : array
4761-
An N-length array (or scalar) of the y data
4763+
y1 : array (length N) or scalar
4764+
The y coordinates of the nodes defining the first curve.
47624765
4763-
y2 : array
4764-
An N-length array (or scalar) of the y data
4766+
y2 : array (length N) or scalar, optional, default: 0
4767+
The y coordinates of the nodes defining the second curve.
47654768
4766-
where : array, optional
4767-
If `None`, default to fill between everywhere. If not `None`,
4768-
it is an N-length numpy boolean array and the fill will
4769-
only happen over the regions where ``where==True``.
4769+
where : array of bool (length N), optional, default: None
4770+
Define *where* to exclude some horizontal regions from being
4771+
filled. The filled regions are defined by the coordinates
4772+
``x[where]``. More precisely, fill between ``x[i]`` and ``x[i+1]``
4773+
if ``where[i] and where[i+1]``. Note that this definition implies
4774+
that an isolated *True* value between two *False* values in
4775+
*where* will not result in filling. Both sides of the *True*
4776+
position remain unfilled due to the adjacent *False* values.
47704777
47714778
interpolate : bool, optional
4772-
If `True`, interpolate between the two lines to find the
4773-
precise point of intersection. Otherwise, the start and
4774-
end points of the filled region will only occur on explicit
4775-
values in the *x* array.
4779+
This option is only relvant if *where* is used and the two curves
4780+
are crossing each other.
47764781
4777-
step : {'pre', 'post', 'mid'}, optional
4778-
If not None, fill with step logic.
4782+
Semantically, *where* is often used for *y1* > *y2* or similar.
4783+
By default, the nodes of the polygon defining the filled region
4784+
will only be placed at the positions in the *x* array. Such a
4785+
polygon cannot describe the above semantics close to the
4786+
intersection. The x-sections containing the intersecion are
4787+
simply clipped.
47794788
4780-
Returns
4781-
-------
4782-
`PolyCollection`
4783-
Plotted polygon collection
4789+
Setting *interpolate* to *True* will calculate the actual
4790+
interscection point and extend the filled region up to this point.
47844791
4785-
Notes
4786-
-----
4792+
step : {'pre', 'post', 'mid'}, optional
4793+
Define *step* if the filling should be a step function,
4794+
i.e. constant in between *x*. The value determines where the
4795+
step will occur:
47874796
4788-
Additional Keyword args passed on to the
4789-
:class:`~matplotlib.collections.PolyCollection`.
4797+
- 'pre': The y value is continued constantly to the left from
4798+
every *x* position.
4799+
- 'post': The y value is continued constantly to the right from
4800+
every *x* position.
4801+
- 'mid': Steps occur in the middle between the *x* positions.
47904802
4791-
kwargs control the :class:`~matplotlib.patches.Polygon` properties:
4803+
Other Parameters
4804+
----------------
4805+
**kwargs
4806+
All other keyword arguments are passed on to `~.PolyCollection`.
4807+
They control the `~.Polygon` properties:
47924808
4793-
%(PolyCollection)s
4809+
%(PolyCollection)s
4810+
4811+
Returns
4812+
-------
4813+
`~.PolyCollection`
4814+
A `~.PolyCollection` containing the plotted polygons.
47944815
47954816
See Also
47964817
--------
4818+
fill_betweenx : Fill between two sets of x-values.
47974819
4798-
:meth:`fill_betweenx`
4799-
for filling between two sets of x-values
4820+
Notes
4821+
-----
4822+
.. [notes section required to get data note injection right]
48004823
48014824
"""
4802-
48034825
if not rcParams['_internal.classic_mode']:
48044826
color_aliases = mcoll._color_aliases
48054827
kwargs = cbook.normalize_kwargs(kwargs, color_aliases)
@@ -4904,62 +4926,84 @@ def get_interp_point(ind):
49044926
def fill_betweenx(self, y, x1, x2=0, where=None,
49054927
step=None, interpolate=False, **kwargs):
49064928
"""
4907-
Make filled polygons between two horizontal curves.
4929+
Fill the area between two vertical curves.
4930+
4931+
The curves are defined by the points (*x1*, *y*) and (*x2*, *y*). This
4932+
creates one or multiple polygons describing the filled area.
49084933
4934+
You may exclude some vertical sections from filling using *where*.
4935+
4936+
By default, the edges connect the given points directly. Use *step* if
4937+
the filling should be a step function, i.e. constant in between *y*.
49094938
4910-
Create a :class:`~matplotlib.collections.PolyCollection`
4911-
filling the regions between *x1* and *x2* where
4912-
``where==True``
49134939
49144940
Parameters
49154941
----------
4916-
y : array
4917-
An N-length array of the y data
4918-
4919-
x1 : array
4920-
An N-length array (or scalar) of the x data
4942+
y : array (length N)
4943+
The y coordinates of the nodes defining the curves.
49214944
4922-
x2 : array, optional
4923-
An N-length array (or scalar) of the x data
4945+
x1 : array (length N) or scalar
4946+
The x coordinates of the nodes defining the first curve.
49244947
4925-
where : array, optional
4926-
If *None*, default to fill between everywhere. If not *None*,
4927-
it is a N length numpy boolean array and the fill will
4928-
only happen over the regions where ``where==True``
4948+
x2 : array (length N) or scalar, optional, default: 0
4949+
The x coordinates of the nodes defining the second curve.
49294950
4930-
step : {'pre', 'post', 'mid'}, optional
4931-
If not None, fill with step logic.
4951+
where : array of bool (length N), optional, default: None
4952+
Define *where* to exclude some vertical regions from being
4953+
filled. The filled regions are defined by the coordinates
4954+
``y[where]``. More precisely, fill between ``y[i]`` and ``y[i+1]``
4955+
if ``where[i] and where[i+1]``. Note that this definition implies
4956+
that an isolated *True* value between two *False* values in
4957+
*where* will not result in filling. Both sides of the *True*
4958+
position remain unfilled due to the adjacent *False* values.
49324959
49334960
interpolate : bool, optional
4934-
If `True`, interpolate between the two lines to find the
4935-
precise point of intersection. Otherwise, the start and
4936-
end points of the filled region will only occur on explicit
4937-
values in the *x* array.
4961+
This option is only relvant if *where* is used and the two curves
4962+
are crossing each other.
49384963
4964+
Semantically, *where* is often used for *x1* > *x2* or similar.
4965+
By default, the nodes of the polygon defining the filled region
4966+
will only be placed at the positions in the *y* array. Such a
4967+
polygon cannot describe the above semantics close to the
4968+
intersection. The y-sections containing the intersecion are
4969+
simply clipped.
49394970
4940-
Returns
4941-
-------
4942-
`PolyCollection`
4943-
Plotted polygon collection
4971+
Setting *interpolate* to *True* will calculate the actual
4972+
interscection point and extend the filled region up to this point.
49444973
4945-
Notes
4946-
-----
4974+
step : {'pre', 'post', 'mid'}, optional
4975+
Define *step* if the filling should be a step function,
4976+
i.e. constant in between *y*. The value determines where the
4977+
step will occur:
4978+
4979+
- 'pre': The y value is continued constantly below every *y*
4980+
position.
4981+
- 'post': The y value is continued constantly above every *y*
4982+
position.
4983+
- 'mid': Steps occur in the middle between the *y* positions.
49474984
4948-
keyword args passed on to the
4949-
:class:`~matplotlib.collections.PolyCollection`
4985+
Other Parameters
4986+
----------------
4987+
**kwargs
4988+
All other keyword arguments are passed on to `~.PolyCollection`.
4989+
They control the `~.Polygon` properties:
49504990
4951-
kwargs control the :class:`~matplotlib.patches.Polygon` properties:
4991+
%(PolyCollection)s
49524992
4953-
%(PolyCollection)s
4993+
Returns
4994+
-------
4995+
`~.PolyCollection`
4996+
A `~.PolyCollection` containing the plotted polygons.
49544997
49554998
See Also
49564999
--------
5000+
fill_between : Fill between two sets of y-values.
49575001
4958-
:meth:`fill_between`
4959-
for filling between two sets of y-values
5002+
Notes
5003+
-----
5004+
.. [notes section required to get data note injection right]
49605005
49615006
"""
4962-
49635007
if not rcParams['_internal.classic_mode']:
49645008
color_aliases = mcoll._color_aliases
49655009
kwargs = cbook.normalize_kwargs(kwargs, color_aliases)

0 commit comments

Comments
 (0)