MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / create_artists

Method create_artists

lib/matplotlib/legend_handler.py:662–708  ·  view source on GitHub ↗
(self, legend, orig_handle,
                       xdescent, ydescent, width, height, fontsize,
                       trans)

Source from the content-addressed store, hash-verified

660 return ydata
661
662 def create_artists(self, legend, orig_handle,
663 xdescent, ydescent, width, height, fontsize,
664 trans):
665 # docstring inherited
666 markerline, stemlines, baseline = orig_handle
667 # Check to see if the stemcontainer is storing lines as a list or a
668 # LineCollection. Eventually using a list will be removed, and this
669 # logic can also be removed.
670 using_linecoll = isinstance(stemlines, mcoll.LineCollection)
671
672 xdata, xdata_marker = self.get_xdata(legend, xdescent, ydescent,
673 width, height, fontsize)
674
675 ydata = self.get_ydata(legend, xdescent, ydescent,
676 width, height, fontsize)
677
678 if self._bottom is None:
679 bottom = 0.
680 else:
681 bottom = self._bottom
682
683 leg_markerline = Line2D(xdata_marker, ydata[:len(xdata_marker)])
684 self.update_prop(leg_markerline, markerline, legend)
685
686 leg_stemlines = [Line2D([x, x], [bottom, y])
687 for x, y in zip(xdata_marker, ydata)]
688
689 if using_linecoll:
690 # change the function used by update_prop() from the default
691 # to one that handles LineCollection
692 with cbook._setattr_cm(
693 self, _update_prop_func=self._copy_collection_props):
694 for line in leg_stemlines:
695 self.update_prop(line, stemlines, legend)
696
697 else:
698 for lm, m in zip(leg_stemlines, stemlines):
699 self.update_prop(lm, m, legend)
700
701 leg_baseline = Line2D([np.min(xdata), np.max(xdata)],
702 [bottom, bottom])
703 self.update_prop(leg_baseline, baseline, legend)
704
705 artists = [*leg_stemlines, leg_baseline, leg_markerline]
706 for artist in artists:
707 artist.set_transform(trans)
708 return artists
709
710 def _copy_collection_props(self, legend_handle, orig_handle):
711 """

Callers

nothing calls this directly

Calls 7

get_ydataMethod · 0.95
Line2DClass · 0.90
minMethod · 0.80
maxMethod · 0.80
get_xdataMethod · 0.45
update_propMethod · 0.45
set_transformMethod · 0.45

Tested by

no test coverage detected