Skip to content

Commit a16f8d0

Browse files
committed
Legend: include markers test
1 parent 109e759 commit a16f8d0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/matplotlib/tests/test_legend.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,18 @@ def test_legend_remove():
297297
def test_reverse_legend():
298298
fig, ax = plt.subplots()
299299
x = [1, 2, 3]
300-
y = [1, 2, 3], [2, 3, 4], [3, 4, 5]
300+
y = [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
301301
labels = ["First label", "Second label", "Third label"]
302+
markers = ['.', ',', 'o']
302303

303-
ax.plot(x, y, label=labels)
304+
ax.plot(x, y[0], markers[0], label=labels[0])
305+
ax.plot(x, y[1], markers[1], label=labels[1])
306+
ax.plot(x, y[2], markers[2], label=labels[2])
304307
leg = ax.legend(reverse=True)
305-
actual_labels = [t.get_gext() for t in leg.get_texts()]
306-
assert actual_labels == list(reversed(labels))
308+
actual_labels = [t.get_text() for t in leg.get_texts()]
309+
actual_markers = [h.get_marker() for h in leg.legend_handles]
310+
assert (actual_labels, actual_markers) == (list(reversed(labels)),
311+
(list(reversed(markers))))
307312

308313

309314
class TestLegendFunction:

0 commit comments

Comments
 (0)