Closed
Description
Bug report
Legend handles and labels retrieval break as of 2.1.1
. Trying to call ax.get_legend_handles_labels()
results in a comparison ValueError
being thrown. git bisect
led to 4f594f4 being the start of the issue.
Code for reproduction
%matplotlib inline
import collections
import matplotlib.pyplot as plt
import numpy as np
X = np.random.randn(10)
Y = np.random.randn(10)
labels = ['a'] * 5 + ['b'] * 5
colors = ['r'] * 5 + ['g'] * 5
fig, ax = plt.subplots()
for x, y, label, color in zip(X, Y, labels, colors):
ax.scatter(x, y, label=label, c=color)
handles, labels = ax.get_legend_handles_labels()
Actual outcome
...in _in_handles(h, l)
1342 pass
1343 try:
-> 1344 if f_h.get_facecolor() != h.get_facecolor():
1345 continue
1346 except AttributeError:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Expected outcome
Produce a scatter plot, as expected. This worked in 2.1.0
.
Matplotlib version
- Operating system: Ubuntu 16.04 and macOS 10.13
- Matplotlib version: 2.1.1
- Matplotlib backend (
print(matplotlib.get_backend())
): agg on both - Python version: 3.5.4
- Jupyter version (if applicable): 4.4.0
- Other libraries:
Metadata
Metadata
Assignees
Labels
No labels