@@ -28,6 +28,7 @@ def legend_artist(self, legend, orig_handle, fontsize, handlebox)
28
28
29
29
import numpy as np
30
30
31
+ from matplotlib import cbook
31
32
from matplotlib .lines import Line2D
32
33
from matplotlib .patches import Rectangle
33
34
import matplotlib .collections as mcoll
@@ -607,19 +608,15 @@ def create_artists(self, legend, orig_handle,
607
608
if using_linecoll :
608
609
# change the function used by update_prop() from the default
609
610
# to one that handles LineCollection
610
- orig_update_func = self ._update_prop_func
611
- self ._update_prop_func = self ._copy_collection_props
612
-
613
- for line in leg_stemlines :
614
- self .update_prop (line , stemlines , legend )
611
+ with cbook ._setattr_cm (
612
+ self , _update_prop_func = self ._copy_collection_props ):
613
+ for line in leg_stemlines :
614
+ self .update_prop (line , stemlines , legend )
615
615
616
616
else :
617
617
for lm , m in zip (leg_stemlines , stemlines ):
618
618
self .update_prop (lm , m , legend )
619
619
620
- if using_linecoll :
621
- self ._update_prop_func = orig_update_func
622
-
623
620
leg_baseline = Line2D ([np .min (xdata ), np .max (xdata )],
624
621
[bottom , bottom ])
625
622
self .update_prop (leg_baseline , baseline , legend )
0 commit comments