8000 Fix issue with non-string labels and legend · matplotlib/matplotlib@15218fa · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

8000
Appearance settings

Commit 15218fa

Browse files
committed
Fix issue with non-string labels and legend
1 parent f71555a commit 15218fa

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/matplotlib/container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __new__(cls, *args, **kwargs):
1919
def __init__(self, kl, label=None):
2020
self._callbacks = cbook.CallbackRegistry(signals=["pchanged"])
2121
self._remove_method = None
22-
self._label = label
22+
self._label = str(label) if label is not None else None
2323

2424
def remove(self):
2525
for c in cbook.flatten(

lib/matplotlib/tests/test_container.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import numpy as np
12
import matplotlib.pyplot as plt
23

34

@@ -28,3 +29,9 @@ def test_errorbar_remove():
2829

2930
eb = ax.errorbar([1], [1], fmt='none')
3031
eb.remove()
32+
33+
34+
def test_nonstring_label():
35+
# Test for #26824
36+
plt.bar(np.arange(10), np.random.rand(10), label=1)
37+
plt.legend()

0 commit comments

Comments
 (0)
0