Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2b96bc

Browse files
authored
Merge pull request #10186 from timhoffm/axes-doc-fill-between
improve docstrings of Axes.fill_between and Axes.fill_betweenx
2 parents e219883 + 82da01b commit a2b96bc

File tree

1 file changed

+113
-69
lines changed

1 file changed

+113
-69
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 113 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4764,64 +4764,86 @@ def fill(self, *args, **kwargs):
47644764
label_namer=None)
47654765
@docstring.dedent_interpd
47664766
def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
4767-
step=None,
4768-
**kwargs):
4767+
step=None, **kwargs):
47694768
"""
4770-
Make filled polygons between two curves.
4769+
Fill the area between two horizontal curves.
47714770
4771+
The curves are defined by the points (*x*, *y1*) and (*x*, *y2*). This
4772+
creates one or multiple polygons describing the filled area.
4773+
4774+
You may exclude some horizontal sections from filling using *where*.
4775+
4776+
By default, the edges connect the given points directly. Use *step* if
4777+
the filling should be a step function, i.e. constant in between *x*.
47724778
4773-
Create a :class:`~matplotlib.collections.PolyCollection`
4774-
filling the regions between *y1* and *y2* where
4775-
``where==True``
47764779
47774780
Parameters
47784781
----------
4779-
x : array
4780-
An N-length array of the x data
4782+
x : array (length N)
4783+
The x coordinates of the nodes defining the curves.
47814784
4782-
y1 : array
4783-
An N-length array (or scalar) of the y data
4785+
y1 : array (length N) or scalar
4786+
The y coordinates of the nodes defining the first curve.
47844787
4785-
y2 : array
4786-
An N-length array (or scalar) of the y data
4788+
y2 : array (length N) or scalar, optional, default: 0
4789+
The y coordinates of the nodes defining the second curve.
47874790
4788-
where : array, optional
4789-
If `None`, default to fill between everywhere. If not `None`,
4790-
it is an N-length numpy boolean array and the fill will
4791-
only happen over the regions where ``where==True``.
4791+
where : array of bool (length N), optional, default: None
4792+
Define *where* to exclude some horizontal regions from being
4793+
filled. The filled regions are defined by the coordinates
4794+
``x[where]``. More precisely, fill between ``x[i]`` and ``x[i+1]``
4795+
if ``where[i] and where[i+1]``. Note that this definition implies
4796+
that an isolated *True* value between two *False* values in
4797+
*where* will not result in filling. Both sides of the *True*
4798+
position remain unfilled due to the adjacent *False* values.
47924799
47934800
interpolate : bool, optional
4794-
If `True`, interpolate between the two lines to find the
4795-
precise point of intersection. Otherwise, the start and
4796-
end points of the filled region will only occur on explicit
4797-
values in the *x* array.
4801+
This option is only relvant if *where* is used and the two curves
4802+
are crossing each other.
47984803
4799-
step : {'pre', 'post', 'mid'}, optional
4800-
If not None, fill with step logic.
4804+
Semantically, *where* is often used for *y1* > *y2* or similar.
4805+
By default, the nodes of the polygon defining the filled region
4806+
will only be placed at the positions in the *x* array. Such a
4807+
polygon cannot describe the above semantics close to the
4808+
intersection. The x-sections containing the intersecion are
4809+
simply clipped.
48014810
4802-
Returns
4803-
-------
4804-
`PolyCollection`
4805-
Plotted polygon collection
4811+
Setting *interpolate* to *True* will calculate the actual
4812+
interscection point and extend the filled region up to this point.
48064813
4807-
Notes
4808-
-----
4814+
step : {'pre', 'post', 'mid'}, optional
4815+
Define *step* if the filling should be a step function,
4816+
i.e. constant in between *x*. The value determines where the
4817+
step will occur:
48094818
4810-
Additional Keyword args passed on to the
4811-
:class:`~matplotlib.collections.PolyCollection`.
4819+
- 'pre': The y value is continued constantly to the left from
4820+
every *x* position.
4821+
- 'post': The y value is continued constantly to the right from
4822+
every *x* position.
4823+
- 'mid': Steps occur in the middle between the *x* positions.
48124824
4813-
kwargs control the :class:`~matplotlib.patches.Polygon` properties:
4825+
Other Parameters
4826+
----------------
4827+
**kwargs
4828+
All other keyword arguments are passed on to `~.PolyCollection`.
4829+
They control the `~.Polygon` properties:
48144830
4815-
%(PolyCollection)s
4831+
%(PolyCollection)s
4832+
4833+
Returns
4834+
-------
4835+
`~.PolyCollection`
4836+
A `~.PolyCollection` containing the plotted polygons.
48164837
48174838
See Also
48184839
--------
4840+
fill_betweenx : Fill between two sets of x-values.
48194841
4820-
:meth:`fill_betweenx`
4821-
for filling between two sets of x-values
4842+
Notes
4843+
-----
4844+
.. [notes section required to get data note injection right]
48224845
48234846
"""
4824-
48254847
if not rcParams['_internal.classic_mode']:
48264848
color_aliases = mcoll._color_aliases
48274849
kwargs = cbook.normalize_kwargs(kwargs, color_aliases)
@@ -4926,62 +4948,84 @@ def get_interp_point(ind):
49264948
def fill_betweenx(self, y, x1, x2=0, where=None,
49274949
step=None, interpolate=False, **kwargs):
49284950
"""
4929-
Make filled polygons between two horizontal curves.
4951+
Fill the area between two vertical curves.
4952+
4953+
The curves are defined by the points (*x1*, *y*) and (*x2*, *y*). This
4954+
creates one or multiple polygons describing the filled area.
49304955
4956+
You may exclude some vertical sections from filling using *where*.
4957+
4958+
By default, the edges connect the given points directly. Use *step* if
4959+
the filling should be a step function, i.e. constant in between *y*.
49314960
4932-
Create a :class:`~matplotlib.collections.PolyCollection`
4933-
filling the regions between *x1* and *x2* where
4934-
``where==True``
49354961
49364962
Parameters
49374963
----------
4938-
y : array
4939-
An N-length array of the y data
4940-
4941-
x1 : array
4942-
An N-length array (or scalar) of the x data
4964+
y : array (length N)
4965+
The y coordinates of the nodes defining the curves.
49434966
4944-
x2 : array, optional
4945-
An N-length array (or scalar) of the x data
4967+
x1 : array (length N) or scalar
4968+
The x coordinates of the nodes defining the first curve.
49464969
4947-
where : array, optional
4948-
If *None*, default to fill between everywhere. If not *None*,
4949-
it is a N length numpy boolean array and the fill will
4950-
only happen over the regions where ``where==True``
4970+
x2 : array (length N) or scalar, optional, default: 0
4971+
The x coordinates of the nodes defining the second curve.
49514972
4952-
step : {'pre', 'post', 'mid'}, optional
4953-
If not None, fill with step logic.
4973+
where : array of bool (length N), optional, default: None
4974+
Define *where* to exclude some vertical regions from being
4975+
filled. The filled regions are defined by the coordinates
4976+
``y[where]``. More precisely, fill between ``y[i]`` and ``y[i+1]``
4977+
if ``where[i] and where[i+1]``. Note that this definition implies
4978+
that an isolated *True* value between two *False* values in
4979+
*where* will not result in filling. Both sides of the *True*
4980+
position remain unfilled due to the adjacent *False* values.
49544981
49554982
interpolate : bool, optional
4956-
If `True`, interpolate between the two lines to find the
4957-
precise point of intersection. Otherwise, the start and
4958-
end points of the filled region will only occur on explicit
4959-
values in the *x* array.
4983+
This option is only relvant if *where* is used and the two curves
4984+
are crossing each other.
49604985
4986+
Semantically, *where* is often used for *x1* > *x2* or similar.
4987+
By default, the nodes of the polygon defining the filled region
4988+
will only be placed at the positions in the *y* array. Such a
4989+
polygon cannot describe the above semantics close to the
4990+
intersection. The y-sections containing the intersecion are
4991+
simply clipped.
49614992
4962-
Returns
4963-
-------
4964-
`PolyCollection`
4965-
Plotted polygon collection
4993+
Setting *interpolate* to *True* will calculate the actual
4994+
interscection point and extend the filled region up to this point.
49664995
4967-
Notes
4968-
-----
4996+
step : {'pre', 'post', 'mid'}, optional
4997+
Define *step* if the filling should be a step function,
4998+
i.e. constant in between *y*. The value determines where the
4999+
step will occur:
5000+
5001+
- 'pre': The y value is continued constantly below every *y*
5002+
position.
5003+
- 'post': The y value is continued constantly above every *y*
5004+
position.
5005+
- 'mid': Steps occur in the middle between the *y* positions.
49695006
4970-
keyword args passed on to the
4971-
:class:`~matplotlib.collections.PolyCollection`
5007+
Other Parameters
5008+
----------------
5009+
**kwargs
5010+
All other keyword arguments are passed on to `~.PolyCollection`.
5011+
They control the `~.Polygon` properties:
49725012
4973-
kwargs control the :class:`~matplotlib.patches.Polygon` properties:
5013+
%(PolyCollection)s
49745014
4975-
%(PolyCollection)s
5015+
Returns
5016+
-------
5017+
`~.PolyCollection`
5018+
A `~.PolyCollection` containing the plotted polygons.
49765019
49775020
See Also
49785021
--------
5022+
fill_between : Fill between two sets of y-values.
49795023
4980-
:meth:`fill_between`
4981-
for filling between two sets of y-values
5024+
Notes
5025+
-----
5026+
.. [notes section required to get data note injection right]
49825027
49835028
"""
4984-
49855029
if not rcParams['_internal.classic_mode']:
49865030
color_aliases = mcoll._color_aliases
49875031
kwargs = cbook.normalize_kwargs(kwargs, color_aliases)

0 commit comments

Comments
 (0)