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

Skip to content

Commit 1e23003

Browse files
committed
Raise an ValueError when Axes.pie accepts negative values
1 parent 508f21f commit 1e23003

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2921,6 +2921,10 @@ def pie(self, x, explode=None, labels=None, colors=None,
29212921
"and will be removed %(removal)s; pass a 1D array instead.")
29222922
x = np.atleast_1d(x.squeeze())
29232923

2924+
for part in x:
2925+
if part < 0:
2926+
raise ValueError("wedge sizes must be non negative values")
2927+
29242928
sx = x.sum()
29252929
if sx > 1:
29262930
x = x / sx

0 commit comments

Comments
 (0)