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

Method legend_artist

lib/matplotlib/legend_handler.py:103–138  ·  view source on GitHub ↗

Return the artist that this HandlerBase generates for the given original artist/handle. Parameters ---------- legend : `~matplotlib.legend.Legend` The legend for which these legend artists are being created. orig_handle : :class:`matplotl

(self, legend, orig_handle,
                      fontsize, handlebox)

Source from the content-addressed store, hash-verified

101 return xdescent, ydescent, width, height
102
103 def legend_artist(self, legend, orig_handle,
104 fontsize, handlebox):
105 """
106 Return the artist that this HandlerBase generates for the given
107 original artist/handle.
108
109 Parameters
110 ----------
111 legend : `~matplotlib.legend.Legend`
112 The legend for which these legend artists are being created.
113 orig_handle : :class:`matplotlib.artist.Artist` or similar
114 The object for which these legend artists are being created.
115 fontsize : int
116 The fontsize in pixels. The artists being created should
117 be scaled according to the given fontsize.
118 handlebox : `~matplotlib.offsetbox.OffsetBox`
119 The box which has been created to hold this legend entry's
120 artists. Artists created in the `legend_artist` method must
121 be added to this handlebox inside this method.
122
123 """
124 xdescent, ydescent, width, height = self.adjust_drawing_area(
125 legend, orig_handle,
126 handlebox.xdescent, handlebox.ydescent,
127 handlebox.width, handlebox.height,
128 fontsize)
129 artists = self.create_artists(legend, orig_handle,
130 xdescent, ydescent, width, height,
131 fontsize, handlebox.get_transform())
132
133 # create_artists will return a list of artists.
134 for a in artists:
135 handlebox.add_artist(a)
136
137 # we only return the first artist
138 return artists[0]
139
140 def create_artists(self, legend, orig_handle,
141 xdescent, ydescent, width, height, fontsize,

Callers 1

_init_legend_boxMethod · 0.45

Calls 4

adjust_drawing_areaMethod · 0.95
create_artistsMethod · 0.95
get_transformMethod · 0.45
add_artistMethod · 0.45

Tested by

no test coverage detected