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

Skip to content

Commit 5345cb6

Browse files
committed
Deprecate allowing scalars for fill_between where
1 parent 64ba969 commit 5345cb6

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Passing scalars to parameter where in ``fill_between()`` and ``fill_betweenx()``
2+
````````````````````````````````````````````````````````````````````````````````
3+
4+
Passing scalars to parameter *where* in ``fill_between()`` and
5+
``fill_betweenx()`` is deprecated. While the documentation already states that
6+
*where* must be of the same size as *x* (or *y*), scalars were accepted and
7+
broadcasted to the size of *x*. Non-matching sizes will raise a ``ValueError``
8+
in the future.

lib/matplotlib/axes/_axes.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5175,6 +5175,14 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
51755175

51765176
if where is None:
51775177
where = True
5178+
else:
5179+
where = np.asarray(where, dtype=bool)
5180+
if where.size != x.size:
5181+
cbook.warn_deprecated(
5182+
"3.2",
5183+
message="The parameter where must have the same size as x "
5184+
"in fill_between(). This will become an error in "
5185+
"future versions of Matplotlib.")
51785186
where = where & ~functools.reduce(np.logical_or,
51795187
map(np.ma.getmask, [x, y1, y2]))
51805188

@@ -5356,6 +5364,14 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
53565364

53575365
if where is None:
53585366
where = True
5367+
else:
5368+
where = np.asarray(where, dtype=bool)
5369+
if where.size != y.size:
5370+
cbook.warn_deprecated(
5371+
"3.2",
5372+
message="The parameter where must have the same size as y "
5373+
"in fill_between(). This will become an error in "
5374+
"future versions of Matplotlib.")
53595375
where = where & ~functools.reduce(np.logical_or,
53605376
map(np.ma.getmask, [y, x1, x2]))
53615377

0 commit comments

Comments
 (0)