Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2e39575

Browse filesBrowse files
committed
Standardize description of kwargs in legend_handler.
Rename `kw` to the standard `kwargs`. In the docstring, use a relatively standard formulation already used in other modules. HandlerStepPatch doesn't need to override `__init__` at all. Move the description of HandlerTuple's parameters into `__init__`, as for other classes (in this module and elsewhere).
1 parent 57489bf commit 2e39575
Copy full SHA for 2e39575

File tree

Expand file treeCollapse file tree

1 file changed

+39
-54
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+39
-54
lines changed

‎lib/matplotlib/legend_handler.py

Copy file name to clipboardExpand all lines: lib/matplotlib/legend_handler.py
+39-54Lines changed: 39 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,19 @@ class HandlerNpoints(HandlerBase):
136136
"""
137137
A legend handler that shows *numpoints* points in the legend entry.
138138
"""
139-
def __init__(self, marker_pad=0.3, numpoints=None, **kw):
139+
140+
def __init__(self, marker_pad=0.3, numpoints=None, **kwargs):
140141
"""
141142
Parameters
142143
----------
143144
marker_pad : float
144145
Padding between points in legend entry.
145-
146146
numpoints : int
147147
Number of points to show in legend entry.
148-
149-
Notes
150-
-----
151-
Any other keyword arguments are given to `HandlerBase`.
148+
**kwargs
149+
Keyword arguments forwarded to `.HandlerBase`.
152150
"""
153-
super().__init__(**kw)
151+
super().__init__(**kwargs)
154152

155153
self._numpoints = numpoints
156154
self._marker_pad = marker_pad
@@ -181,22 +179,20 @@ class HandlerNpointsYoffsets(HandlerNpoints):
181179
A legend handler that shows *numpoints* in the legend, and allows them to
182180
be individually offset in the y-direction.
183181
"""
184-
def __init__(self, numpoints=None, yoffsets=None, **kw):
182+
183+
def __init__(self, numpoints=None, yoffsets=None, **kwargs):
185184
"""
186185
Parameters
187186
----------
188187
numpoints : int
189188
Number of points to show in legend entry.
190-
191189
yoffsets : array of floats
192190
Length *numpoints* list of y offsets for each point in
193191
legend entry.
194-
195-
Notes
196-
-----
197-
Any other keyword arguments are given to `HandlerNpoints`.
192+
**kwargs
193+
Keyword arguments forwarded to `.HandlerNpoints`.
198194
"""
199-
super().__init__(numpoints=numpoints, **kw)
195+
super().__init__(numpoints=numpoints, **kwargs)
200196
self._yoffsets = yoffsets
201197

202198
def get_ydata(self, legend, xdescent, ydescent, width, height, fontsize):
@@ -212,21 +208,18 @@ class HandlerLine2D(HandlerNpoints):
212208
"""
213209
Handler for `.Line2D` instances.
214210
"""
215-
def __init__(self, marker_pad=0.3, numpoints=None, **kw):
211+
def __init__(self, marker_pad=0.3, numpoints=None, **kwargs):
216212
"""
217213
Parameters
218214
----------
219215
marker_pad : float
220216
Padding between points in legend entry.
221-
222217
numpoints : int
223218
Number of points to show in legend entry.
224-
225-
Notes
226-
-----
227-
Any other keyword arguments are given to `HandlerNpoints`.
219+
**kwargs
220+
Keyword arguments forwarded to `.HandlerNpoints`.
228221
"""
229-
super().__init__(marker_pad=marker_pad, numpoints=numpoints, **kw)
222+
super().__init__(marker_pad=marker_pad, numpoints=numpoints, **kwargs)
230223

231224
def create_artists(self, legend, orig_handle,
232225
xdescent, ydescent, width, height, fontsize,
@@ -263,7 +256,8 @@ class HandlerPatch(HandlerBase):
263256
"""
264257
Handler for `.Patch` instances.
265258
"""
266-
def __init__(self, patch_func=None, **kw):
259+
260+
def __init__(self, patch_func=None, **kwargs):
267261
"""
268262
Parameters
269263
----------
@@ -278,11 +272,10 @@ def patch_func(legend=legend, orig_handle=orig_handle,
278272
Subsequently the created artist will have its ``update_prop``
279273
method called and the appropriate transform will be applied.
280274
281-
Notes
282-
-----
283-
Any other keyword arguments are given to `HandlerBase`.
275+
**kwargs
276+
Keyword arguments forwarded to `.HandlerBase`.
284277
"""
285-
super().__init__(**kw)
278+
super().__init__(**kwargs)
286279
self._patch_func = patch_func
287280

288281
def _create_patch(self, legend, orig_handle,
@@ -309,11 +302,6 @@ class HandlerStepPatch(HandlerBase):
309302
"""
310303
Handler for `~.matplotlib.patches.StepPatch` instances.
311304
"""
312-
def __init__(self, **kw):
313-
"""
314-
Any other keyword arguments are given to `HandlerBase`.
315-
"""
316-
super().__init__(**kw)
317305

318306
def _create_patch(self, legend, orig_handle,
319307
xdescent, ydescent, width, height, fontsize):
@@ -385,8 +373,8 @@ def create_artists(self, legend, orig_handle,
385373
class HandlerRegularPolyCollection(HandlerNpointsYoffsets):
386374
r"""Handler for `.RegularPolyCollection`\s."""
387375

388-
def __init__(self, yoffsets=None, sizes=None, **kw):
389-
super().__init__(yoffsets=yoffsets, **kw)
376+
def __init__(self, yoffsets=None, sizes=None, **kwargs):
377+
super().__init__(yoffsets=yoffsets, **kwargs)
390378

391379
self._sizes = sizes
392380

@@ -481,12 +469,12 @@ class HandlerErrorbar(HandlerLine2D):
481469
"""Handler for Errorbars."""
482470

483471
def __init__(self, xerr_size=0.5, yerr_size=None,
484-
marker_pad=0.3, numpoints=None, **kw):
472+
marker_pad=0.3, numpoints=None, **kwargs):
485473

486474
self._xerr_size = xerr_size
487475
self._yerr_size = yerr_size
488476

489-
super().__init__(marker_pad=marker_pad, numpoints=numpoints, **kw)
477+
super().__init__(marker_pad=marker_pad, numpoints=numpoints, **kwargs)
490478

491479
def get_err_size(self, legend, xdescent, ydescent,
492480
width, height, fontsize):
@@ -588,30 +576,26 @@ class HandlerStem(HandlerNpointsYoffsets):
588576
"""
589577
Handler for plots produced by `~.Axes.stem`.
590578
"""
579+
591580
def __init__(self, marker_pad=0.3, numpoints=None,
592-
bottom=None, yoffsets=None, **kw):
581+
bottom=None, yoffsets=None, **kwargs):
593582
"""
594583
Parameters
595584
----------
596585
marker_pad : float, default: 0.3
597586
Padding between points in legend entry.
598-
599587
numpoints : int, optional
600588
Number of points to show in legend entry.
601-
602589
bottom : float, optional
603590
604591
yoffsets : array of floats, optional
605592
Length *numpoints* list of y offsets for each point in
606593
legend entry.
607-
608-
Notes
609-
-----
610-
Any other keyword arguments are given to `HandlerNpointsYoffsets`.
594+
**kwargs
595+
Keyword arguments forwarded to `.HandlerNpointsYoffsets`.
611596
"""
612-
613597
super().__init__(marker_pad=marker_pad, numpoints=numpoints,
614-
yoffsets=yoffsets, **kw)
598+
yoffsets=yoffsets, **kwargs)
615599
self._bottom = bottom
616600

617601
def get_ydata(self, legend, xdescent, ydescent, width, height, fontsize):
@@ -681,19 +665,20 @@ def _copy_collection_props(self, legend_handle, orig_handle):
681665
class HandlerTuple(HandlerBase):
682666
"""
683667
Handler for Tuple.
684-
685-
Additional kwargs are passed through to `HandlerBase`.
686-
687-
Parameters
688-
----------
689-
ndivide : int, default: 1
690-
The number of sections to divide the legend area into. If None,
691-
use the length of the input tuple.
692-
pad : float, default: :rc:`legend.borderpad`
693-
Padding in units of fraction of font size.
694668
"""
695669

696670
def __init__(self, ndivide=1, pad=None, **kwargs):
671+
"""
672+
Parameters
673+
----------
674+
ndivide : int, default: 1
675+
The number of sections to divide the legend area into. If None,
676+
use the length of the input tuple.
677+
pad : float, default: :rc:`legend.borderpad`
678+
Padding in units of fraction of font size.
679+
**kwargs
680+
Keyword arguments forwarded to `.HandlerBase`.
681+
"""
697682
self._ndivide = ndivide
698683
self._pad = pad
699684
super().__init__(**kwargs)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.