From ae5c8e26e53a4011d4f32491a535d0f212a9269d Mon Sep 17 00:00:00 2001 From: Adam Gomaa Date: Thu, 6 Jun 2019 15:29:00 -0700 Subject: [PATCH] Fix NameError in example code for setting label via method The example code currently raises a NameError as "line" is not defined until the 2nd line is run. --- lib/matplotlib/axes/_axes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index ceacd014ef7a..5b1a3d39f493 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -321,8 +321,8 @@ def legend(self, *args, **kwargs): or:: - line.set_label('Label via method') line, = ax.plot([1, 2, 3]) + line.set_label('Label via method') ax.legend() Specific lines can be excluded from the automatic legend element