@@ -589,7 +589,6 @@ def get_ydata(self, legend, xdescent, ydescent, width, height, fontsize):
589
589
def create_artists (self , legend , orig_handle ,
590
590
xdescent , ydescent , width , height , fontsize ,
591
591
trans ):
592
-
593
592
markerline , stemlines , baseline = orig_handle
594
593
595
594
xdata , xdata_marker = self .get_xdata (legend , xdescent , ydescent ,
@@ -607,9 +606,18 @@ def create_artists(self, legend, orig_handle,
607
606
self .update_prop (leg_markerline , markerline , legend )
608
607
609
608
leg_stemlines = []
609
+
610
+ # update_prop() usually takes two Line2D collections;
611
+ # override temporarily to copy properties from a LineCollection
612
+ orig_update_func = self ._update_prop_func
613
+ self ._update_prop_func = self ._copy_collection_props
614
+
610
615
for thisx , thisy in zip (xdata_marker , ydata ):
611
616
thisline = Line2D ([thisx , thisx ], [bottom , thisy ])
612
617
leg_stemlines .append (thisline )
618
+ self .update_prop (thisline , stemlines , legend )
619
+ # Reset update_prop_func
620
+ self ._update_prop_func = orig_update_func
613
621
614
622
leg_baseline = Line2D ([np .min (xdata ), np .max (xdata )],
615
623
[bottom , bottom ])
@@ -625,6 +633,13 @@ def create_artists(self, legend, orig_handle,
625
633
626
634
return artists
627
635
636
+ def _copy_collection_props (self , legend_handle , orig_handle ):
637
+ '''
638
+ Method to copy properties from a LineCollection (orig_handle) to a
639
+ Line2D (legend_handle).
640
+ '''
641
+ legend_handle ._color = orig_handle .get_color ()[0 ]
642
+
628
643
629
644
class HandlerTuple (HandlerBase ):
630
645
"""
0 commit comments