@@ -580,7 +580,6 @@ def get_ydata(self, legend, xdescent, ydescent, width, height, fontsize):
580
580
def create_artists (self , legend , orig_handle ,
581
581
xdescent , ydescent , width , height , fontsize ,
582
582
trans ):
583
-
584
583
markerline , stemlines , baseline = orig_handle
585
584
586
585
xdata , xdata_marker = self .get_xdata (legend , xdescent , ydescent ,
@@ -598,9 +597,18 @@ def create_artists(self, legend, orig_handle,
598
597
self .update_prop (leg_markerline , markerline , legend )
599
598
600
599
leg_stemlines = []
600
+
601
+ # update_prop() usually takes two Line2D collections;
602
+ # override temporarily to copy properties from a LineCollection
603
+ orig_update_func = self ._update_prop_func
604
+ self ._update_prop_func = self ._copy_collection_props
605
+
601
606
for thisx , thisy in zip (xdata_marker , ydata ):
602
607
thisline = Line2D ([thisx , thisx ], [bottom , thisy ])
603
608
leg_stemlines .append (thisline )
609
+ self .update_prop (thisline , stemlines , legend )
610
+ # Reset update_prop_func
611
+ self ._update_prop_func = orig_update_func
604
612
605
613
leg_baseline = Line2D ([np .min (xdata ), np .max (xdata )],
606
614
[bottom , bottom ])
@@ -616,6 +624,13 @@ def create_artists(self, legend, orig_handle,
616
624
617
625
return artists
618
626
627
+ def _copy_collection_props (self , legend_handle , orig_handle ):
628
+ '''
629
+ Method to copy properties from a LineCollection (orig_handle) to a
630
+ Line2D (legend_handle).
631
+ '''
632
+ legend_handle ._color = orig_handle .get_color ()[0 ]
633
+
619
634
620
635
class HandlerTuple (HandlerBase ):
621
636
"""
0 commit comments