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

Method _update_prop

lib/matplotlib/legend_handler.py:777–802  ·  view source on GitHub ↗
(self, legend_handle, orig_handle)

Source from the content-addressed store, hash-verified

775 `~.Axes.stackplot`.
776 """
777 def _update_prop(self, legend_handle, orig_handle):
778 def first_color(colors):
779 if colors.size == 0:
780 return (0, 0, 0, 0)
781 return tuple(colors[0])
782
783 def get_first(prop_array):
784 if len(prop_array):
785 return prop_array[0]
786 else:
787 return None
788
789 # orig_handle is a PolyCollection and legend_handle is a Patch.
790 # Directly set Patch color attributes (must be RGBA tuples).
791 legend_handle._facecolor = first_color(orig_handle.get_facecolor())
792 legend_handle._edgecolor = first_color(orig_handle.get_edgecolor())
793 legend_handle._hatch_color = first_color(orig_handle.get_hatchcolor())
794 legend_handle._original_facecolor = orig_handle._original_facecolor
795 legend_handle._original_edgecolor = orig_handle._original_edgecolor
796 legend_handle._fill = orig_handle.get_fill()
797 legend_handle._hatch = orig_handle.get_hatch()
798 # Setters are fine for the remaining attributes.
799 legend_handle.set_linewidth(get_first(orig_handle.get_linewidths()))
800 legend_handle.set_linestyle(get_first(orig_handle.get_linestyles()))
801 legend_handle.set_transform(get_first(orig_handle.get_transforms()))
802 # Alpha is already taken into account by the color attributes.
803
804 def create_artists(self, legend, orig_handle,
805 xdescent, ydescent, width, height, fontsize, trans):

Callers

nothing calls this directly

Calls 10

get_linewidthsMethod · 0.80
get_transformsMethod · 0.80
get_facecolorMethod · 0.45
get_edgecolorMethod · 0.45
get_hatchcolorMethod · 0.45
get_fillMethod · 0.45
get_hatchMethod · 0.45
set_linewidthMethod · 0.45
set_linestyleMethod · 0.45
set_transformMethod · 0.45

Tested by

no test coverage detected