Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f7228d

Browse files
committed
Remove code duplication
1 parent 6b19ba6 commit 1f7228d

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

lib/matplotlib/legend_handler.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -618,27 +618,20 @@ def create_artists(self, legend, orig_handle,
618618
orig_update_func = self._update_prop_func
619619
self._update_prop_func = self._copy_collection_props
620620

621-
for thisx, thisy in zip(xdata_marker, ydata):
622-
thisline = Line2D([thisx, thisx], [bottom, thisy])
623-
leg_stemlines.append(thisline)
624-
self.update_prop(thisline, stemlines, legend)
621+
for line in leg_stemlines:
622+
self.update_prop(line, stemlines, legend)
625623

626-
self._update_prop_func = orig_update_func
627624
else:
628-
for thisx, thisy in zip(xdata_marker, ydata):
629-
thisline = Line2D([thisx, thisx], [bottom, thisy])
630-
leg_stemlines.append(thisline)
631625
for lm, m in zip(leg_stemlines, stemlines):
632626
self.update_prop(lm, m, legend)
633627

628+
if using_linecoll:
629+
self._update_prop_func = orig_update_func
630+
634631
leg_baseline = Line2D([np.min(xdata), np.max(xdata)],
635632
[bottom, bottom])
636-
637633
self.update_prop(leg_baseline, baseline, legend)
638634

639-
leg_markerline = Line2D(xdata_marker, ydata[:len(xdata_marker)])
640-
self.update_prop(leg_markerline, markerline, legend)
641-
642635
artists = leg_stemlines
643636
artists.append(leg_baseline)
644637
artists.append(leg_markerline)

0 commit comments

Comments
 (0)