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

Class HandlerTuple

lib/matplotlib/legend_handler.py:719–769  ·  view source on GitHub ↗

Handler for Tuple.

Source from the content-addressed store, hash-verified

717
718
719class HandlerTuple(HandlerBase):
720 """
721 Handler for Tuple.
722 """
723
724 def __init__(self, ndivide=1, pad=None, **kwargs):
725 """
726 Parameters
727 ----------
728 ndivide : int or None, default: 1
729 The number of sections to divide the legend area into. If None,
730 use the length of the input tuple.
731 pad : float, default: :rc:`legend.borderpad`
732 Padding in units of fraction of font size.
733 **kwargs
734 Keyword arguments forwarded to `.HandlerBase`.
735 """
736 self._ndivide = ndivide
737 self._pad = pad
738 super().__init__(**kwargs)
739
740 def create_artists(self, legend, orig_handle,
741 xdescent, ydescent, width, height, fontsize,
742 trans):
743 # docstring inherited
744 handler_map = legend.get_legend_handler_map()
745
746 if self._ndivide is None:
747 ndivide = len(orig_handle)
748 else:
749 ndivide = self._ndivide
750
751 if self._pad is None:
752 pad = legend.borderpad * fontsize
753 else:
754 pad = self._pad * fontsize
755
756 if ndivide > 1:
757 width = (width - pad * (ndivide - 1)) / ndivide
758
759 xds_cycle = cycle(xdescent - (width + pad) * np.arange(ndivide))
760
761 a_list = []
762 for handle1 in orig_handle:
763 handler = legend.get_legend_handler(handler_map, handle1)
764 _a_list = handler.create_artists(
765 legend, handle1,
766 next(xds_cycle), ydescent, width, height, fontsize, trans)
767 a_list.extend(_a_list)
768
769 return a_list
770
771
772class HandlerPolyCollection(HandlerBase):

Callers 3

test_multiple_keysFunction · 0.90
legend_guide.pyFile · 0.90
legend_demo.pyFile · 0.90

Calls

no outgoing calls

Tested by 1

test_multiple_keysFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…