8000 Merge pull request #11975 from anntzer/figlegend-docstring · matplotlib/matplotlib@a3dc2e1 · GitHub
[go: up one dir, main page]

Skip to content

Commit a3dc2e1

Browse files
authored
Merge pull request #11975 from anntzer/figlegend-docstring
Derive plt.figlegend.__doc__ from Figure.legend.__doc__.
2 parents 488563f + fa0229e commit a3dc2e1

File tree

2 files changed

+14
-40
lines changed

2 files changed

+14
-40
lines changed

lib/matplotlib/figure.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,10 @@ def get_axes(self):
16801680
"""
16811681
return self.axes
16821682

1683+
# Note: in the docstring below, the newlines in the examples after the
1684+
# calls to legend() allow replacing it with figlegend() to generate the
1685+
# docstring of pyplot.figlegend.
1686+
16831687
@docstring.dedent_interpd
16841688
def legend(self, *args, **kwargs):
16851689
"""
@@ -1691,15 +1695,17 @@ def legend(self, *args, **kwargs):
16911695
16921696
To make a legend for a list of lines and labels::
16931697
1694-
legend( (line1, line2, line3),
1695-
('label1', 'label2', 'label3'),
1696-
loc='upper right')
1698+
legend(
1699+
(line1, line2, line3),
1700+
('label1', 'label2', 'label3'),
1701+
loc='upper right')
16971702
16981703
These can also be specified by keyword::
16991704
1700-
legend(handles=(line1, line2, line3),
1701-
labels=('label1', 'label2', 'label3'),
1702-
loc=&# 8000 39;upper right')
1705+
legend(
1706+
handles=(line1, line2, line3),
1707+
labels=('label1', 'label2', 'label3'),
1708+
loc='upper right')
17031709
17041710
Parameters
17051711
----------

lib/matplotlib/pyplot.py

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -756,41 +756,9 @@ def figimage(*args, **kwargs):
756756

757757

758758
def figlegend(*args, **kwargs):
759-
"""
760-
Place a legend in the figure.
761-
762-
*labels*
763-
a sequence of strings
764-
765-
*handles*
766-
a sequence of :class:`~matplotlib.lines.Line2D` or
767-
:class:`~matplotlib.patches.Patch` instances
768-
769-
*loc*
770-
can be a string or an integer specifying the legend
771-
location
772-
773-
A :class:`matplotlib.legend.Legend` instance is returned.
774-
775-
Examples
776-
--------
777-
778-
To make a legend from existing artists on every axes::
779-
780-
figlegend()
781-
782-
To make a legend for a list of lines and labels::
783-
784-
figlegend( (line1, line2, line3),
785-
('label1', 'label2', 'label3'),
786-
'upper right' )
787-
788-
.. seealso::
789-
790-
:func:`~matplotlib.pyplot.legend`
791-
792-
"""
793759
return gcf().legend(*args, **kwargs)
760+
if Figure.legend.__doc__:
761+
figlegend.__doc__ = Figure.legend.__doc__.replace("legend(", "figlegend(")
794762

795763

796764
## Axes ##

0 commit comments

Comments
 (0)
0