Skip to content

Commit 1efbafb

Browse files
committed
fixed test_legend
1 parent b8cfebb commit 1efbafb

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

doc/users/next_whats_new/2019-12-09-legend-textcolor.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ Textcolor for legend labels
44
The text color of legend labels can now be set by passing a parameter
55
``textcolor`` to `~.axes.Axes.legend`. The ``textcolor`` keyword can be:
66

7-
* A single color (either a string or RGBA tuple), which adjusts the color of
8-
all of labels.
9-
* A list or tuple, allowing the color of each label text to be set
10-
individually.
11-
* ``linecolor``, which sets the color of each label to match the corresponding
12-
line color.
13-
* ``markerfacecolor``, which sets the color of each label to match the
7+
* A single color (either a string or RGBA tuple), which adjusts the text color
8+
of all the labels.
9+
* A list or tuple, allowing the text color of each label to be set individually.
10+
* ``linecolor``, which sets the text color of each label to match the
11+
corresponding line color.
12+
* ``markerfacecolor``, which sets the test color of each label to match the
1413
corresponding marker face color
15-
* ``markeredgecolor``, which sets the color of each label to match the
14+
* ``markeredgecolor``, which sets the text color of each label to match the
1615
corresponding marker edge color

lib/matplotlib/tests/test_legend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ def test_legend_textcolor_linecolor():
565565

566566
leg = ax.legend(textcolor='linecolor')
567567
for text, color in zip(leg.get_texts(), ['r', 'g', 'b']):
568-
assert text.get_color() == color
568+
assert mpl.colors.same_color(text.get_color(), color)
569569

570570

571571
def test_legend_textcolor_markeredgecolor():
@@ -577,7 +577,7 @@ def test_legend_textcolor_markeredgecolor():
577577

578578
leg = ax.legend(textcolor='markeredgecolor')
579579
for text, color in zip(leg.get_texts(), ['r', 'g', 'b']):
580-
assert text.get_color() == color
580+
assert mpl.colors.same_color(text.get_color(), color)
581581

582582

583583
def test_legend_textcolor_markerfacecolor():
@@ -589,7 +589,7 @@ def test_legend_textcolor_markerfacecolor():
589589

590590
leg = ax.legend(textcolor='markerfacecolor')
591591
for text, color in zip(leg.get_texts(), ['r', 'g', 'b']):
592-
assert text.get_color() == color
592+
assert mpl.colors.same_color(text.get_color(), color)
593593

594594

595595
def test_get_set_draggable():

0 commit comments

Comments
 (0)