13
13
import matplotlib
14
14
15
15
import matplotlib .cbook as cbook
16
- from matplotlib .cbook import _string_to_bool , mplDeprecation
16
+ from matplotlib .cbook import mplDeprecation , STEP_LOOKUP_MAP
17
17
import matplotlib .collections as mcoll
18
18
import matplotlib .colors as mcolors
19
19
import matplotlib .contour as mcontour
@@ -4428,13 +4428,11 @@ def fill(self, *args, **kwargs):
4428
4428
4429
4429
@docstring .dedent_interpd
4430
4430
def fill_between (self , x , y1 , y2 = 0 , where = None , interpolate = False ,
4431
+ step_where = None ,
4431
4432
** kwargs ):
4432
4433
"""
4433
4434
Make filled polygons between two curves.
4434
4435
4435
- Call signature::
4436
-
4437
- fill_between(x, y1, y2=0, where=None, **kwargs)
4438
4436
4439
4437
Create a :class:`~matplotlib.collections.PolyCollection`
4440
4438
filling the regions between *y1* and *y2* where
@@ -4462,9 +4460,12 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
4462
4460
end points of the filled region will only occur on explicit
4463
4461
values in the *x* array.
4464
4462
4463
+ step_where : {'pre', 'post', 'mid'}, optional
4464
+ If not None, fill with step logic.
4465
+
4465
4466
4466
- Note
4467
- ----
4467
+ Notes
4468
+ -----
4468
4469
4469
4470
Additional Keyword args passed on to the
4470
4471
:class:`~matplotlib.collections.PolyCollection`.
@@ -4516,6 +4517,9 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
4516
4517
xslice = x [ind0 :ind1 ]
4517
4518
y1slice = y1 [ind0 :ind1 ]
4518
4519
y2slice = y2 [ind0 :ind1 ]
4520
+ if step_where is not None :
4521
+ step_func = STEP_LOOKUP_MAP [step_where ]
4522
+ xslice , y1slice , y2slice = step_func (xslice , y1slice , y2slice )
4519
4523
4520
4524
if not len (xslice ):
4521
4525
continue
@@ -4576,7 +4580,8 @@ def get_interp_point(ind):
4576
4580
return collection
4577
4581
4578
4582
@docstring .dedent_interpd
4579
- def fill_betweenx (self , y , x1 , x2 = 0 , where = None , ** kwargs ):
4583
+ def fill_betweenx (self , y , x1 , x2 = 0 , where = None ,
4584
+ step_where = None , ** kwargs ):
4580
4585
"""
4581
4586
Make filled polygons between two horizontal curves.
4582
4587
@@ -4588,19 +4593,27 @@ def fill_betweenx(self, y, x1, x2=0, where=None, **kwargs):
4588
4593
filling the regions between *x1* and *x2* where
4589
4594
``where==True``
4590
4595
4591
- *y* :
4596
+ Parameters
4597
+ ----------
4598
+ y : array
4592
4599
An N-length array of the y data
4593
4600
4594
- *x1* :
4601
+ x1 : array
4595
4602
An N-length array (or scalar) of the x data
4596
4603
4597
- *x2* :
4604
+ x2 : array, optional
4598
4605
An N-length array (or scalar) of the x data
4599
4606
4600
- *where* :
4601
- If *None*, default to fill between everywhere. If not *None*,
4602
- it is a N length numpy boolean array and the fill will
4603
- only happen over the regions where ``where==True``
4607
+ where : array, optional
4608
+ If *None*, default to fill between everywhere. If not *None*,
4609
+ it is a N length numpy boolean array and the fill will
4610
+ only happen over the regions where ``where==True``
4611
+
4612
+ step_where : {'pre', 'post', 'mid'}, optional
4613
+ If not None, fill with step logic.
4614
+
4615
+ Notes
4616
+ -----
4604
4617
4605
4618
*kwargs* :
4606
4619
keyword args passed on to the
@@ -4610,9 +4623,13 @@ def fill_betweenx(self, y, x1, x2=0, where=None, **kwargs):
4610
4623
4611
4624
%(PolyCollection)s
4612
4625
4626
+ Examples
4627
+ --------
4628
+
4613
4629
.. plot:: mpl_examples/pylab_examples/fill_betweenx_demo.py
4614
4630
4615
- .. seealso::
4631
+ See Also
4632
+ --------
4616
4633
4617
4634
:meth:`fill_between`
4618
4635
for filling between two sets of y-values
@@ -4649,6 +4666,9 @@ def fill_betweenx(self, y, x1, x2=0, where=None, **kwargs):
4649
4666
yslice = y [ind0 :ind1 ]
4650
4667
x1slice = x1 [ind0 :ind1 ]
4651
4668
x2slice = x2 [ind0 :ind1 ]
4669
+ if step_where is not None :
4670
+ step_func = STEP_LOOKUP_MAP [step_where ]
4671
+ yslice , x1slice , x2slice = step_func (yslice , x1slice , x2slice )
4652
4672
4653
4673
if not len (yslice ):
4654
4674
continue
0 commit comments