10000 Merge pull request #14511 from timhoffm/deprecate-fill_between-where_… · matplotlib/matplotlib@965540c · GitHub
[go: up one dir, main page]

Skip to content

Commit 965540c

Browse files
authored
Merge pull request #14511 from timhoffm/deprecate-fill_between-where_scalar
API: Deprecate allowing scalars for fill_between where
2 parents d197f42 + 5345cb6 commit 965540c

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
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
@@ -5169,6 +5169,14 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
51695169

51705170
if where is None:
51715171
where = True
5172+
else:
5173+
where = np.asarray(where, dtype=bool)
5174+
if where.size != x.size:
5175+
cbook.warn_deprecated(
5176+
"3.2",
5177+
message="The parameter where must have the same size as x "
5178+
"in fill_between(). This will become an error in "
5179+
"future versions of Matplotlib.")
51725180
where = where & ~functools.reduce(np.logical_or,
51735181
map(np.ma.getmask, [x, y1, y2]))
51745182

@@ -5350,6 +5358,14 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
53505358

53515359
if where is None:
53525360
where = True
5361+
else:
5362+
where = np.asarray(where, dtype=bool)
5363+
if where.size != y.size:
5364+
cbook.warn_deprecated(
5365+
"3.2",
5366+
message="The parameter where must have the same size as y "
5367+
"in fill_between(). This will become an error in "
5368+
"future versions of Matplotlib.")
53535369
where = where & ~functools.reduce(np.logical_or,
53545370
map(np.ma.getmask, [y, x1, x2]))
53555371

0 commit comments

Comments
 (0)
0