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

Skip to content

Commit 819b99d

Browse files
committed
TST: test for hist labels allowing singletons
1 parent a3b33fe commit 819b99d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,6 +3073,21 @@ def test_hist_emptydata():
30733073
ax.hist([[], range(10), range(10)], histtype="step")
30743074

30753075

3076+
def test_hist_labels():
3077+
# test singleton labels OK
3078+
fig, ax = plt.subplots()
3079+
l = ax.hist([0, 1], label=0)
3080+
assert l[2][0].get_label() == '0'
3081+
l = ax.hist([0, 1], label=[0])
3082+
assert l[2][0].get_label() == '0'
3083+
l = ax.hist([0, 1], label=None)
3084+
assert l[2][0].get_label() == '_nolegend_'
3085+
l = ax.hist([0, 1], label='0')
3086+
assert l[2][0].get_label() == '0'
3087+
l = ax.hist([0, 1], label='00')
3088+
assert l[2][0].get_label() == '00'
3089+
3090+
30763091
@image_comparison(baseline_images=['transparent_markers'], remove_text=True)
30773092
def test_transparent_markers():
30783093
np.random.seed(0)

0 commit comments

Comments
 (0)