Skip to content

Commit 41162b3

Browse files
committed
Improve tests as suggested in PR
1 parent 66ec3a0 commit 41162b3

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/matplotlib/tests/test_legend.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -691,25 +691,19 @@ def test_legend_pathcollection_labelcolor_linecolor_iterable():
691691
ax.scatter(np.arange(10), np.arange(10)*1, label='#1', c=colors)
692692

693693
leg = ax.legend(labelcolor='linecolor')
694-
for text, color in zip(leg.get_texts(), ['k']):
695-
assert mpl.colors.same_color(text.get_color(), color)
694+
text, = leg.get_texts()
695+
assert mpl.colors.same_color(text, 'black')
696696

697697

698698
def test_legend_pathcollection_labelcolor_linecolor_cmap():
699699
# test the labelcolor for labelcolor='linecolor' on PathCollection
700700
# with a colormap
701701
fig, ax = plt.subplots()
702-
ax.scatter(
703-
np.arange(10),
704-
np.arange(10),
705-
label='#1',
706-
c=np.arange(10),
707-
cmap="Reds"
708-
)
702+
ax.scatter(np.arange(10), np.arange(10), c=np.arange(10), label='#1')
709703

710704
leg = ax.legend(labelcolor='linecolor')
711-
for text, color in zip(leg.get_texts(), ['k']):
712-
assert mpl.colors.same_color(text.get_color(), color)
705+
text, = leg.get_texts()
706+
assert mpl.colors.same_color(text, 'black')
713707

714708

715709
def test_legend_labelcolor_markeredgecolor():

0 commit comments

Comments
 (0)