Skip to content

Commit 4257416

Browse files
authored
Merge pull request #10799 from jklymak/doc-interp-legenddocstring
DOC: make legend docstring interpolated
2 parents 4841a02 + ded8822 commit 4257416

File tree

4 files changed

+3
-533
lines changed

4 files changed

+3
-533
lines changed

lib/matplotlib/axes/_axes.py

+1-166
Original file line numberDiff line numberDiff line change
@@ -354,172 +354,7 @@ def legend(self, *args, **kwargs):
354354
Other Parameters
355355
----------------
356356
357-
loc : int or string or pair of floats, default: 'upper right'
358-
The location of the legend. Possible codes are:
359-
360-
=============== =============
361-
Location String Location Code
362-
=============== =============
363-
'best' 0
364-
'upper right' 1
365-
'upper left' 2
366-
'lower left' 3
367-
'lower right' 4
368-
'right' 5
369-
'center left' 6
370-
'center right' 7
371-
'lower center' 8
372-
'upper center' 9
373-
'center' 10
374-
=============== =============
375-
376-
377-
Alternatively can be a 2-tuple giving ``x, y`` of the lower-left
378-
corner of the legend in axes coordinates (in which case
379-
``bbox_to_anchor`` will be ignored).
380-
381-
bbox_to_anchor : `.BboxBase` or pair of floats
382-
Specify any arbitrary location for the legend in `bbox_transform`
383-
coordinates (default Axes coordinates).
384-
385-
For example, to put the legend's upper right hand corner in the
386-
center of the axes the following keywords can be used::
387-
388-
loc='upper right', bbox_to_anchor=(0.5, 0.5)
389-
390-
ncol : integer
391-
The number of columns that the legend has. Default is 1.
392-
393-
prop : None or :class:`matplotlib.font_manager.FontProperties` or dict
394-
The font properties of the legend. If None (default), the current
395-
:data:`matplotlib.rcParams` will be used.
396-
397-
fontsize : int or float or {'xx-small', 'x-small', 'small', 'medium', \
398-
'large', 'x-large', 'xx-large'}
399-
Controls the font size of the legend. If the value is numeric the
400-
size will be the absolute font size in points. String values are
401-
relative to the current default font size. This argument is only
402-
used if `prop` is not specified.
403-
404-
numpoints : None or int
405-
The number of marker points in the legend when creating a legend
406-
entry for a `.Line2D` (line).
407-
Default is ``None``, which will take the value from
408-
:rc:`legend.numpoints`.
409-
410-
scatterpoints : None or int
411-
The number of marker points in the legend when creating
412-
a legend entry for a `.PathCollection` (scatter plot).
413-
Default is ``None``, which will take the value from
414-
:rc:`legend.scatterpoints`.
415-
416-
scatteryoffsets : iterable of floats
417-
The vertical offset (relative to the font size) for the markers
418-
created for a scatter plot legend entry. 0.0 is at the base the
419-
legend text, and 1.0 is at the top. To draw all markers at the
420-
same height, set to ``[0.5]``. Default is ``[0.375, 0.5, 0.3125]``.
421-
422-
markerscale : None or int or float
423-
The relative size of legend markers compared with the originally
424-
drawn ones.
425-
Default is ``None``, which will take the value from
426-
:rc:`legend.markerscale`.
427-
428-
markerfirst : bool
429-
If *True*, legend marker is placed to the left of the legend label.
430-
If *False*, legend marker is placed to the right of the legend
431-
label.
432-
Default is *True*.
433-
434-
frameon : None or bool
435-
Control whether the legend should be drawn on a patch
436-
(frame).
437-
Default is ``None``, which will take the value from
438-
:rc:`legend.frameon`.
439-
440-
fancybox : None or bool
441-
Control whether round edges should be enabled around the
442-
:class:`~matplotlib.patches.FancyBboxPatch` which makes up the
443-
legend's background.
444-
Default is ``None``, which will take the value from
445-
:rc:`legend.fancybox`.
446-
447-
shadow : None or bool
448-
Control whether to draw a shadow behind the legend.
449-
Default is ``None``, which will take the value from
450-
:rc:`legend.shadow`.
451-
452-
framealpha : None or float
453-
Control the alpha transparency of the legend's background.
454-
Default is ``None``, which will take the value from
455-
:rc:`legend.framealpha`. If shadow is activated and
456-
*framealpha* is ``None``, the default value is ignored.
457-
458-
facecolor : None or "inherit" or a color spec
459-
Control the legend's background color.
460-
Default is ``None``, which will take the value from
461-
:rc:`legend.facecolor`. If ``"inherit"``, it will take
462-
:rc:`axes.facecolor`.
463-
464-
edgecolor : None or "inherit" or a color spec
465-
Control the legend's background patch edge color.
466-
Default is ``None``, which will take the value from
467-
:rc:`legend.edgecolor` If ``"inherit"``, it will take
468-
:rc:`axes.edgecolor`.
469-
470-
mode : {"expand", None}
471-
If `mode` is set to ``"expand"`` the legend will be horizontally
472-
expanded to fill the axes area (or `bbox_to_anchor` if defines
473-
the legend's size).
474-
475-
bbox_transform : None or :class:`matplotlib.transforms.Transform`
476-
The transform for the bounding box (`bbox_to_anchor`). For a value
477-
of ``None`` (default) the Axes'
478-
:data:`~matplotlib.axes.Axes.transAxes` transform will be used.
479-
480-
title : str or None
481-
The legend's title. Default is no title (``None``).
482-
483-
borderpad : float or None
484-
The fractional whitespace inside the legend border.
485-
Measured in font-size units.
486-
Default is ``None``, which will take the value from
487-
:rc:`legend.borderpad`.
488-
489-
labelspacing : float or None
490-
The vertical space between the legend entries.
491-
Measured in font-size units.
492-
Default is ``None``, which will take the value from
493-
:rc:`legend.labelspacing`.
494-
495-
handlelength : float or None
496-
The length of the legend handles.
497-
Measured in font-size units.
498-
Default is ``None``, which will take the value from
499-
:rc:`legend.handlelength`.
500-
501-
handletextpad : float or None
502-
The pad between the legend handle and text.
503-
Measured in font-size units.
504-
Default is ``None``, which will take the value from
505-
:rc:`legend.handletextpad`.
506-
507-
borderaxespad : float or None
508-
The pad between the axes and legend border.
509-
Measured in font-size units.
510-
Default is ``None``, which will take the value from
511-
:rc:`legend.borderaxespad`.
512-
513-
columnspacing : float or None
514-
The spacing between columns.
515-
Measured in font-size units.
516-
Default is ``None``, which will take the value from
517-
:rc:`legend.columnspacing`.
518-
519-
handler_map : dict or None
520-
The custom dictionary mapping instances or types to a legend
521-
handler. This `handler_map` updates the default handler map
522-
found at :func:`matplotlib.legend.Legend.get_legend_handler_map`.
357+
%(_legend_kw_doc)s
523358
524359
Returns
525360
-------

lib/matplotlib/figure.py

+1-166
Original file line numberDiff line numberDiff line change
@@ -1574,172 +1574,7 @@ def legend(self, *args, **kwargs):
15741574
Other Parameters
15751575
----------------
15761576
1577-
loc : int or string or pair of floats, default: 'upper right'
1578-
The location of the legend. Possible codes are:
1579-
1580-
=============== =============
1581-
Location String Location Code
1582-
=============== =============
1583-
'best' 0
1584-
'upper right' 1
1585-
'upper left' 2
1586-
'lower left' 3
1587-
'lower right' 4
1588-
'right' 5
1589-
'center left' 6
1590-
'center right' 7
1591-
'lower center' 8
1592-
'upper center' 9
1593-
'center' 10
1594-
=============== =============
1595-
1596-
1597-
Alternatively can be a 2-tuple giving ``x, y`` of the lower-left
1598-
corner of the legend in axes coordinates (in which case
1599-
``bbox_to_anchor`` will be ignored).
1600-
1601-
bbox_to_anchor : `.BboxBase` or pair of floats
1602-
Specify any arbitrary location for the legend in `bbox_transform`
1603-
coordinates (default Axes coordinates).
1604-
1605-
For example, to put the legend's upper right hand corner in the
1606-
center of the axes the following keywords can be used::
1607-
1608-
loc='upper right', bbox_to_anchor=(0.5, 0.5)
1609-
1610-
ncol : integer
1611-
The number of columns that the legend has. Default is 1.
1612-
1613-
prop : None or :class:`matplotlib.font_manager.FontProperties` or dict
1614-
The font properties of the legend. If None (default), the current
1615-
:data:`matplotlib.rcParams` will be used.
1616-
1617-
fontsize : int or float or {'xx-small', 'x-small', 'small', 'medium', \
1618-
'large', 'x-large', 'xx-large'}
1619-
Controls the font size of the legend. If the value is numeric the
1620-
size will be the absolute font size in points. String values are
1621-
relative to the current default font size. This argument is only
1622-
used if `prop` is not specified.
1623-
1624-
numpoints : None or int
1625-
The number of marker points in the legend when creating a legend
1626-
entry for a `.Line2D` (line).
1627-
Default is ``None``, which will take the value from
1628-
:rc:`legend.numpoints`.
1629-
1630-
scatterpoints : None or int
1631-
The number of marker points in the legend when creating
1632-
a legend entry for a `.PathCollection` (scatter plot).
1633-
Default is ``None``, which will take the value from
1634-
:rc:`legend.scatterpoints`.
1635-
1636-
scatteryoffsets : iterable of floats
1637-
The vertical offset (relative to the font size) for the markers
1638-
created for a scatter plot legend entry. 0.0 is at the base the
1639-
legend text, and 1.0 is at the top. To draw all markers at the
1640-
same height, set to ``[0.5]``. Default is ``[0.375, 0.5, 0.3125]``.
1641-
1642-
markerscale : None or int or float
1643-
The relative size of legend markers compared with the originally
1644-
drawn ones.
1645-
Default is ``None``, which will take the value from
1646-
:rc:`legend.markerscale`.
1647-
1648-
markerfirst : bool
1649-
If *True*, legend marker is placed to the left of the legend label.
1650-
If *False*, legend marker is placed to the right of the legend
1651-
label.
1652-
Default is *True*.
1653-
1654-
frameon : None or bool
1655-
Control whether the legend should be drawn on a patch
1656-
(frame).
1657-
Default is ``None``, which will take the value from
1658-
:rc:`legend.frameon`.
1659-
1660-
fancybox : None or bool
1661-
Control whether round edges should be enabled around the
1662-
:class:`~matplotlib.patches.FancyBboxPatch` which makes up the
1663-
legend's background.
1664-
Default is ``None``, which will take the value from
1665-
:rc:`legend.fancybox`.
1666-
1667-
shadow : None or bool
1668-
Control whether to draw a shadow behind the legend.
1669-
Default is ``None``, which will take the value from
1670-
:rc:`legend.shadow`.
1671-
1672-
framealpha : None or float
1673-
Control the alpha transparency of the legend's background.
1674-
Default is ``None``, which will take the value from
1675-
:rc:`legend.framealpha`. If shadow is activated and
1676-
*framealpha* is ``None``, the default value is ignored.
1677-
1678-
facecolor : None or "inherit" or a color spec
1679-
Control the legend's background color.
1680-
Default is ``None``, which will take the value from
1681-
:rc:`legend.facecolor`. If ``"inherit"``, it will take
1682-
:rc:`axes.facecolor`.
1683-
1684-
edgecolor : None or "inherit" or a color spec
1685-
Control the legend's background patch edge color.
1686-
Default is ``None``, which will take the value from
1687-
:rc:`legend.edgecolor` If ``"inherit"``, it will take
1688-
:rc:`axes.edgecolor`.
1689-
1690-
mode : {"expand", None}
1691-
If `mode` is set to ``"expand"`` the legend will be horizontally
1692-
expanded to fill the axes area (or `bbox_to_anchor` if defines
1693-
the legend's size).
1694-
1695-
bbox_transform : None or :class:`matplotlib.transforms.Transform`
1696-
The transform for the bounding box (`bbox_to_anchor`). For a value
1697-
of ``None`` (default) the Axes'
1698-
:data:`~matplotlib.axes.Axes.transAxes` transform will be used.
1699-
1700-
title : str or None
1701-
The legend's title. Default is no title (``None``).
1702-
1703-
borderpad : float or None
1704-
The fractional whitespace inside the legend border.
1705-
Measured in font-size units.
1706-
Default is ``None``, which will take the value from
1707-
:rc:`legend.borderpad`.
1708-
1709-
labelspacing : float or None
1710-
The vertical space between the legend entries.
1711-
Measured in font-size units.
1712-
Default is ``None``, which will take the value from
1713-
:rc:`legend.labelspacing`.
1714-
1715-
handlelength : float or None
1716-
The length of the legend handles.
1717-
Measured in font-size units.
1718-
Default is ``None``, which will take the value from
1719-
:rc:`legend.handlelength`.
1720-
1721-
handletextpad : float or None
1722-
The pad between the legend handle and text.
1723-
Measured in font-size units.
1724-
Default is ``None``, which will take the value from
1725-
:rc:`legend.handletextpad`.
1726-
1727-
borderaxespad : float or None
1728-
The pad between the axes and legend border.
1729-
Measured in font-size units.
1730-
Default is ``None``, which will take the value from
1731-
:rc:`legend.borderaxespad`.
1732-
1733-
columnspacing : float or None
1734-
The spacing between columns.
1735-
Measured in font-size units.
1736-
Default is ``None``, which will take the value from
1737-
:rc:`legend.columnspacing`.
1738-
1739-
handler_map : dict or None
1740-
The custom dictionary mapping instances or types to a legend
1741-
handler. This `handler_map` updates the default handler map
1742-
found at :func:`matplotlib.legend.Legend.get_legend_handler_map`.
1577+
%(_legend_kw_doc)s
17431578
17441579
Returns
17451580
-------

0 commit comments

Comments
 (0)