Skip to content

Commit ec6014f

Browse files
committed
Improve pie chart error messages
Fix typo in error message, add more detail and make formatting consistent
1 parent 8552c7a commit ec6014f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,9 +3283,9 @@ def pie(self, x, explode=None, labels=None, colors=None,
32833283
if explode is None:
32843284
explode = [0] * len(x)
32853285
if len(x) != len(labels):
3286-
raise ValueError("'label' must be of length 'x'")
3286+
raise ValueError(f"'labels' must be of length 'x', not {len(labels)}")
32873287
if len(x) != len(explode):
3288-
raise ValueError("'explode' must be of length 'x'")
3288+
raise ValueError(f"'explode' must be of length 'x', not {len(explode)}")
32893289
if colors is None:
32903290
get_next_color = self._get_patches_for_fill.get_next_color
32913291
else:
@@ -3298,7 +3298,7 @@ def get_next_color():
32983298

32993299
_api.check_isinstance(Real, radius=radius, startangle=startangle)
33003300
if radius <= 0:
3301-
raise ValueError(f'radius must be a positive number, not {radius}')
3301+
raise ValueError(f"'radius' must be a positive number, not {radius}")
33023302

33033303
# Starting theta1 is the start fraction of the circle
33043304
theta1 = startangle / 360

0 commit comments

Comments
 (0)