Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/2018-02-03-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Deprecations
````````````

Passing a non-1D (typically, (n, 1)-shaped) input to `Axes.pie` is deprecated.
Pass a 1D array instead.
12 changes: 10 additions & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2809,11 +2809,19 @@ def pie(self, x, explode=None, labels=None, colors=None,
The axes aspect ratio can be controlled with `Axes.set_aspect`.
"""
self.set_aspect('equal')
x = np.array(x, np.float32)
# The use of float32 is "historical", but can't be changed without
# regenerating the test baselines.
x = np.asarray(x, np.float32)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be changed to float64, and only patched back in some way to float32 for the tests. But that's beyond this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems not worth the effort, frankly

if x.ndim != 1 and x.squeeze().ndim <= 1:
cbook.warn_deprecated(
"3.1", message="Non-1D inputs to pie() are currently "
"squeeze()d, but this behavior is deprecated since %(since)s "
"and will be removed %(removal)s; pass a 1D array instead.")
x = np.atleast_1d(x.squeeze())

sx = x.sum()
if sx > 1:
x /= sx
x = x / sx

if labels is None:
labels = [''] * len(x)
Expand Down