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

Skip to content

Commit cdb077b

Browse files
committed
Raise ValueError for an unnormalized pie() with sum(x) > 1
1 parent e71472a commit cdb077b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2944,7 +2944,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
29442944
29452945
normalize: None or bool, default: None
29462946
When *True*, always make a full pie by normalizing x so that
2947-
``sum(x) == 1``. When *False*, make a partial (or overfull) pie.
2947+
``sum(x) == 1``. *False* makes a partial pie if ``sum(x) <= 1``
2948+
and raises a `ValueError` for ``sum(x) > 1``.
29482949
29492950
When *None*, defaults to *True* if ``sum(x) > 0`` and *False* if
29502951
``sum(x) < 1``.
@@ -3036,6 +3037,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
30363037
normalize = True
30373038
if normalize:
30383039
x = x / sx
3040+
elif sx > 1:
3041+
raise ValueError('Cannot plot an unnormalized pie with sum(x) > 1')
30393042
if labels is None:
30403043
labels = [''] * len(x)
30413044
if explode is None:

0 commit comments

Comments
 (0)