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

Skip to content

Commit a22e82e

Browse files
committed
BUG : relax validation on hist label
Closes #3869
1 parent 326b8d4 commit a22e82e

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5853,11 +5853,8 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
58535853
labels = [None]
58545854
elif is_string_like(label):
58555855
labels = [label]
5856-
elif is_sequence_of_strings(label):
5857-
labels = list(label)
58585856
else:
5859-
raise ValueError(
5860-
'invalid label: must be string or sequence of strings')
5857+
labels = [str(lab) for lab in label]
58615858

58625859
if len(labels) < nx:
58635860
labels += [None] * (nx - len(labels))

lib/matplotlib/tests/test_axes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3409,6 +3409,11 @@ def test_color_None():
34093409
ax.plot([1,2], [1,2], color=None)
34103410
plt.show()
34113411

3412+
@cleanup
3413+
def test_numerical_hist_label():
3414+
fig, ax = plt.subplots()
3415+
ax.hist([range(15)] * 5, label=range(5))
3416+
34123417
if __name__ == '__main__':
34133418
import nose
34143419
import sys

0 commit comments

Comments
 (0)