From ef060f4ccbdfc5b2712b2a8a34c20a31487769e9 Mon Sep 17 00:00:00 2001 From: nepix32 Date: Fri, 23 Dec 2016 08:11:52 +0100 Subject: [PATCH 1/2] Makes eventplot legend work Fixes issue #7662 --- lib/matplotlib/legend_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/legend_handler.py b/lib/matplotlib/legend_handler.py index 2509e330f974..078ce894e936 100644 --- a/lib/matplotlib/legend_handler.py +++ b/lib/matplotlib/legend_handler.py @@ -267,7 +267,7 @@ def get_numpoints(self, legend): return self._numpoints def _default_update_prop(self, legend_handle, orig_handle): - lw = orig_handle.get_linewidth()[0] + lw = orig_handle.get_linewidths()[0] dashes = orig_handle.get_dashes()[0] color = orig_handle.get_colors()[0] legend_handle.set_color(color) From ad74d47a86d98673aaea298fc91cd2f5cf544210 Mon Sep 17 00:00:00 2001 From: nepix32 Date: Mon, 26 Dec 2016 23:49:16 +0100 Subject: [PATCH 2/2] Test eventlog legend added --- lib/matplotlib/tests/test_axes.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index a590b54818d7..dde3c5a806ef 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4871,3 +4871,9 @@ def test_scatter_color_masking(): assert_array_equal(facecolors[1], np.array([0, 0, 0, 1])) assert_array_equal(linecolors[1], np.array([0, 0, 0, 1])) assert linewidths[1] == 3 + + +@cleanup +def test_eventplot_legend(): + plt.eventplot([1.0], label='Label') + plt.legend()