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 7f0e5ee

Browse filesBrowse files
committed
Cleanup legend docstrings.
1 parent 4616f70 commit 7f0e5ee
Copy full SHA for 7f0e5ee

File tree

Expand file treeCollapse file tree

1 file changed

+24
-43
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+24
-43
lines changed

‎lib/matplotlib/legend.py

Copy file name to clipboardExpand all lines: lib/matplotlib/legend.py
+24-43Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _update_bbox_to_anchor(self, loc_in_canvas):
9494
self.legend.set_bbox_to_anchor(loc_in_bbox)
9595

9696

97-
_legend_kw_doc = '''
97+
docstring.interpd.update(_legend_kw_doc="""
9898
loc : str or pair of floats, default: :rc:`legend.loc` ('best' for axes, \
9999
'upper right' for figures)
100100
The location of the legend.
@@ -175,58 +175,49 @@ def _update_bbox_to_anchor(self, loc_in_canvas):
175175
absolute font size in points. String values are relative to the current
176176
default font size. This argument is only used if *prop* is not specified.
177177
178-
numpoints : None or int
178+
numpoints : int, default: :rc:`legend.numpoints`
179179
The number of marker points in the legend when creating a legend
180180
entry for a `.Line2D` (line).
181-
Default is ``None``, which means using :rc:`legend.numpoints`.
182181
183-
scatterpoints : None or int
182+
scatterpoints : int, default: :rc:`legend.scatterpoints`
184183
The number of marker points in the legend when creating
185184
a legend entry for a `.PathCollection` (scatter plot).
186-
Default is ``None``, which means using :rc:`legend.scatterpoints`.
187185
188186
scatteryoffsets : iterable of floats, default: ``[0.375, 0.5, 0.3125]``
189187
The vertical offset (relative to the font size) for the markers
190188
created for a scatter plot legend entry. 0.0 is at the base the
191189
legend text, and 1.0 is at the top. To draw all markers at the
192190
same height, set to ``[0.5]``.
193191
194-
markerscale : None or float
192+
markerscale : float, default: :rc:`legend.markerscale`
195193
The relative size of legend markers compared with the originally
196194
drawn ones.
197-
Default is ``None``, which means using :rc:`legend.markerscale`.
198195
199196
markerfirst : bool, default: True
200197
If *True*, legend marker is placed to the left of the legend label.
201198
If *False*, legend marker is placed to the right of the legend label.
202199
203-
frameon : None or bool
200+
frameon : bool, default: :rc:`legend.frameon`
204201
Whether the legend should be drawn on a patch (frame).
205-
Default is ``None``, which means using :rc:`legend.frameon`.
206202
207-
fancybox : None or bool
203+
fancybox : bool, default: :rc:`legend.fancybox`
208204
Whether round edges should be enabled around the `~.FancyBboxPatch` which
209205
makes up the legend's background.
210-
Default is ``None``, which means using :rc:`legend.fancybox`.
211206
212-
shadow : None or bool
207+
shadow : bool, default: :rc:`legend.shadow`
213208
Whether to draw a shadow behind the legend.
214-
Default is ``None``, which means using :rc:`legend.shadow`.
215209
216-
framealpha : None or float
210+
framealpha : float, default: :rc:`legend.framealpha`
217211
The alpha transparency of the legend's background.
218-
Default is ``None``, which means using :rc:`legend.framealpha`.
219212
If *shadow* is activated and *framealpha* is ``None``, the default value is
220213
ignored.
221214
222-
facecolor : None or "inherit" or color
215+
facecolor : "inherit" or color, default: :rc:`legend.facecolor`
223216
The legend's background color.
224-
Default is ``None``, which means using :rc:`legend.facecolor`.
225217
If ``"inherit"``, use :rc:`axes.facecolor`.
226218
227-
edgecolor : None or "inherit" or color
219+
edgecolor : "inherit" or color, default: :rc:`legend.edgecolor`
228220
The legend's background patch edge color.
229-
Default is ``None``, which means using :rc:`legend.edgecolor`.
230221
If ``"inherit"``, use take :rc:`axes.edgecolor`.
231222
232223
mode : {"expand", None}
@@ -245,37 +236,29 @@ def _update_bbox_to_anchor(self, loc_in_canvas):
245236
title_fontsize: str or None
246237
The fontsize of the legend's title. Default is the default fontsize.
247238
248-
borderpad : float or None
239+
borderpad : float, default: :rc:`legend.borderpad`
249240
The fractional whitespace inside the legend border, in font-size units.
250-
Default is ``None``, which means using :rc:`legend.borderpad`.
251241
252-
labelspacing : float or None
242+
labelspacing : float, default: :rc:`legend.labelspacing`
253243
The vertical space between the legend entries, in font-size units.
254-
Default is ``None``, which means using :rc:`legend.labelspacing`.
255244
256-
handlelength : float or None
245+
handlelength : float, default: :rc:`legend.handlelength`
257246
The length of the legend handles, in font-size units.
258-
Default is ``None``, which means using :rc:`legend.handlelength`.
259247
260-
handletextpad : float or None
248+
handletextpad : float, default: :rc:`legend.handletextpad`
261249
The pad between the legend handle and text, in font-size units.
262-
Default is ``None``, which means using :rc:`legend.handletextpad`.
263250
264-
borderaxespad : float or None
251+
borderaxespad : float, default: :rc:`legend.borderaxespad`
265252
The pad between the axes and legend border, in font-size units.
266-
Default is ``None``, which means using :rc:`legend.borderaxespad`.
267253
268-
columnspacing : float or None
254+
columnspacing : float, default: :rc:`legend.columnspacing`
269255
The spacing between columns, in font-size units.
270-
Default is ``None``, which means using :rc:`legend.columnspacing`.
271256
272257
handler_map : dict or None
273258
The custom dictionary mapping instances or types to a legend
274259
handler. This `handler_map` updates the default handler map
275260
found at :func:`matplotlib.legend.Legend.get_legend_handler_map`.
276-
277-
'''
278-
docstring.interpd.update(_legend_kw_doc=_legend_kw_doc)
261+
""")
279262

280263

281264
class Legend(Artist):
@@ -905,7 +888,7 @@ def draw_frame(self, b):
905888
self.set_frame_on(b)
906889

907890
def get_children(self):
908-
'Return a list of child artists.'
891+
"""Return the list of child artists."""
909892
children = []
910893
if self._legend_box:
911894
children.append(self._legend_box)
@@ -914,23 +897,21 @@ def get_children(self):
914897
return children
915898

916899
def get_frame(self):
917-
'''
918-
Return the `~.patches.Rectangle` instances used to frame the legend.
919-
'''
900+
"""Return the `~.patches.Rectangle` used to frame the legend."""
920901
return self.legendPatch
921902

922903
def get_lines(self):
923-
'Return a list of `~.lines.Line2D` instances in the legend.'
904+
r"""Return the list of `~.lines.Line2D`\s in the legend."""
924905
return [h for h in self.legendHandles if isinstance(h, Line2D)]
925906

926907
def get_patches(self):
927-
'Return a list of `~.patches.Patch` instances in the legend.'
908+
r"""Return the list of `~.patches.Patch`\s in the legend."""
928909
return silent_list('Patch',
929910
[h for h in self.legendHandles
930911
if isinstance(h, Patch)])
931912

932913
def get_texts(self):
933-
'Return a list of `~.text.Text` instances in the legend.'
914+
r"""Return the list of `~.text.Text`\s in the legend."""
934915
return silent_list('Text', self.texts)
935916

936917
def set_title(self, title, prop=None):
@@ -954,11 +935,11 @@ def set_title(self, title, prop=None):
954935
self.stale = True
955936

956937
def get_title(self):
957-
'Return the `.Text` instance for the legend title.'
938+
"""Return the `.Text` instance for the legend title."""
958939
return self._legend_title_box._text
959940

960941
def get_window_extent(self, renderer=None):
961-
'Return extent of the legend.'
942+
# docstring inherited
962943
if renderer is None:
963944
renderer = self.figure._cachedRenderer
964945
return self._legend_box.get_window_extent(renderer=renderer)

0 commit comments

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