1818i.e., this is dpi-scaled value).
1919
2020This module includes definition of several legend handler classes
21- derived from the base class (HandlerBase) with the following method.
21+ derived from the base class (HandlerBase) with the following method::
2222
2323 def legend_artist(self, legend, orig_handle, fontsize, handlebox):
2424
25-
2625"""
2726from __future__ import (absolute_import , division , print_function ,
2827 unicode_literals )
@@ -133,7 +132,23 @@ def create_artists(self, legend, orig_handle,
133132
134133
135134class HandlerNpoints (HandlerBase ):
135+ """
136+ A legend handler that shows *numpoints* points in the legend entry.
137+ """
136138 def __init__ (self , marker_pad = 0.3 , numpoints = None , ** kw ):
139+ """
140+ Parameters
141+ ----------
142+ marker_pad : float
143+ Padding between points in legend entry.
144+
145+ numpoints : int
146+ Number of points to show in legend entry.
147+
148+ Notes
149+ -----
150+ Any other keyword arguments are given to `HandlerBase`.
151+ """
137152 HandlerBase .__init__ (self , ** kw )
138153
139154 self ._numpoints = numpoints
@@ -162,7 +177,25 @@ def get_xdata(self, legend, xdescent, ydescent, width, height, fontsize):
162177
163178
164179class HandlerNpointsYoffsets (HandlerNpoints ):
180+ """
181+ A legend handler that shows *numpoints* in the legend, and allows them to
182+ be individually offest in the y-direction.
183+ """
165184 def __init__ (self , numpoints = None , yoffsets = None , ** kw ):
185+ """
186+ Parameters
187+ ----------
188+ numpoints : int
189+ Number of points to show in legend entry.
190+
191+ yoffsets : array of floats
192+ Length *numpoints* list of y offsets for each point in
193+ legend entry.
194+
195+ Notes
196+ -----
197+ Any other keyword arguments are given to `HandlerNpoints`.
198+ """
166199 HandlerNpoints .__init__ (self , numpoints = numpoints , ** kw )
167200 self ._yoffsets = yoffsets
168201
@@ -177,10 +210,24 @@ def get_ydata(self, legend, xdescent, ydescent, width, height, fontsize):
177210
178211class HandlerLine2D (HandlerNpoints ):
179212 """
180- Handler for Line2D instances.
213+ Handler for `. Line2D` instances.
181214 """
182215 def __init__ (self , marker_pad = 0.3 , numpoints = None , ** kw ):
183- HandlerNpoints .__init__ (self , marker_pad = marker_pad , numpoints = numpoints , ** kw )
216+ """
217+ Parameters
218+ ----------
219+ marker_pad : float
220+ Padding between points in legend entry.
221+
222+ numpoints : int
223+ Number of points to show in legend entry.
224+
225+ Notes
226+ -----
227+ Any other keyword arguments are given to `HandlerNpoints`.
228+ """
229+ HandlerNpoints .__init__ (self , marker_pad = marker_pad ,
230+ numpoints = numpoints , ** kw )
184231
185232 def create_artists (self , legend , orig_handle ,
186233 xdescent , ydescent , width , height , fontsize ,
@@ -215,21 +262,26 @@ def create_artists(self, legend, orig_handle,
215262
216263class HandlerPatch (HandlerBase ):
217264 """
218- Handler for Patch instances.
265+ Handler for `. Patch` instances.
219266 """
220267 def __init__ (self , patch_func = None , ** kw ):
221268 """
222- The HandlerPatch class optionally takes a function ``patch_func``
223- who's responsibility is to create the legend key artist. The
224- ``patch_func`` should have the signature::
269+ Parameters
270+ ----------
271+ patch_func : callable, optional
272+ The function that creates the legend key artist.
273+ *patch_func* should have the signature::
225274
226- def patch_func(legend=legend, orig_handle=orig_handle,
227- xdescent=xdescent, ydescent=ydescent,
228- width=width, height=height, fontsize=fontsize)
275+ def patch_func(legend=legend, orig_handle=orig_handle,
276+ xdescent=xdescent, ydescent=ydescent,
277+ width=width, height=height, fontsize=fontsize)
229278
230- Subsequently the created artist will have its ``update_prop`` method
231- called and the appropriate transform will be applied.
279+ Subsequently the created artist will have its ``update_prop`` method
280+ called and the appropriate transform will be applied.
232281
282+ Notes
283+ -----
284+ Any other keyword arguments are given to `HandlerBase`.
233285 """
234286 HandlerBase .__init__ (self , ** kw )
235287 self ._patch_func = patch_func
@@ -256,7 +308,7 @@ def create_artists(self, legend, orig_handle,
256308
257309class HandlerLineCollection (HandlerLine2D ):
258310 """
259- Handler for LineCollection instances.
311+ Handler for `. LineCollection` instances.
260312 """
261313 def get_numpoints (self , legend ):
262314 if self ._numpoints is None :
@@ -288,7 +340,7 @@ def create_artists(self, legend, orig_handle,
288340
289341class HandlerRegularPolyCollection (HandlerNpointsYoffsets ):
290342 """
291- Handler for RegularPolyCollections.
343+ Handler for `. RegularPolyCollections` .
292344 """
293345 def __init__ (self , yoffsets = None , sizes = None , ** kw ):
294346 HandlerNpointsYoffsets .__init__ (self , yoffsets = yoffsets , ** kw )
@@ -302,7 +354,7 @@ def get_numpoints(self, legend):
302354 return self ._numpoints
303355
304356 def get_sizes (self , legend , orig_handle ,
305- xdescent , ydescent , width , height , fontsize ):
357+ xdescent , ydescent , width , height , fontsize ):
306358 if self ._sizes is None :
307359 handle_sizes = orig_handle .get_sizes ()
308360 if not len (handle_sizes ):
@@ -363,7 +415,7 @@ def create_artists(self, legend, orig_handle,
363415
364416class HandlerPathCollection (HandlerRegularPolyCollection ):
365417 """
366- Handler for PathCollections, which are used by scatter
418+ Handler for `. PathCollections` , which are used by `~.Axes. scatter`.
367419 """
368420 def create_collection (self , orig_handle , sizes , offsets , transOffset ):
369421 p = type (orig_handle )([orig_handle .get_paths ()[0 ]],
@@ -376,7 +428,7 @@ def create_collection(self, orig_handle, sizes, offsets, transOffset):
376428
377429class HandlerCircleCollection (HandlerRegularPolyCollection ):
378430 """
379- Handler for CircleCollections
431+ Handler for `. CircleCollections`.
380432 """
381433 def create_collection (self , orig_handle , sizes , offsets , transOffset ):
382434 p = type (orig_handle )(sizes ,
@@ -388,7 +440,7 @@ def create_collection(self, orig_handle, sizes, offsets, transOffset):
388440
389441class HandlerErrorbar (HandlerLine2D ):
390442 """
391- Handler for Errorbars
443+ Handler for Errorbars.
392444 """
393445 def __init__ (self , xerr_size = 0.5 , yerr_size = None ,
394446 marker_pad = 0.3 , numpoints = None , ** kw ):
@@ -501,10 +553,29 @@ def create_artists(self, legend, orig_handle,
501553
502554class HandlerStem (HandlerNpointsYoffsets ):
503555 """
504- Handler for Errorbars
556+ Handler for plots produced by `~.Axes.stem`.
505557 """
506558 def __init__ (self , marker_pad = 0.3 , numpoints = None ,
507559 bottom = None , yoffsets = None , ** kw ):
560+ """
561+ Parameters
562+ ----------
563+ marker_pad : float
564+ Padding between points in legend entry. Default is 0.3.
565+
566+ numpoints : int, optional
567+ Number of points to show in legend entry.
568+
569+ bottom : float, optional
570+
571+ yoffsets : array of floats, optional
572+ Length *numpoints* list of y offsets for each point in
573+ legend entry.
574+
575+ Notes
576+ -----
577+ Any other keyword arguments are given to `HandlerNpointsYoffsets`.
578+ """
508579
509580 HandlerNpointsYoffsets .__init__ (self , marker_pad = marker_pad ,
510581 numpoints = numpoints ,
@@ -571,18 +642,14 @@ class HandlerTuple(HandlerBase):
571642
572643 Parameters
573644 ----------
574-
575645 ndivide : int, optional
576- The number of sections to divide the legend area into. If None,
646+ The number of sections to divide the legend area into. If None,
577647 use the length of the input tuple. Default is 1.
578648
579649
580650 pad : float, optional
581- If None, fall back to `legend.borderpad` as the default.
651+ If None, fall back to `` legend.borderpad` ` as the default.
582652 In units of fraction of font size. Default is None.
583-
584-
585-
586653 """
587654 def __init__ (self , ndivide = 1 , pad = None , ** kwargs ):
588655
@@ -628,7 +695,7 @@ def create_artists(self, legend, orig_handle,
628695
629696class HandlerPolyCollection (HandlerBase ):
630697 """
631- Handler for PolyCollection used in fill_between and stackplot.
698+ Handler for `. PolyCollection` used in `~.Axes. fill_between` and `~.Axes. stackplot` .
632699 """
633700 def _update_prop (self , legend_handle , orig_handle ):
634701 def first_color (colors ):
@@ -639,6 +706,7 @@ def first_color(colors):
639706 return colors [0 ]
640707 else :
641708 return "none"
709+
642710 def get_first (prop_array ):
643711 if len (prop_array ):
644712 return prop_array [0 ]
0 commit comments