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 fa0229e

Browse filesBrowse files
committed
Derive plt.figlegend.__doc__ from Figure.legend.__doc__.
Sure, we lose the .. seealso:: to pyplot.legend. I think that's a fair tradeoff as the new docstring is much more precise.
1 parent 70cef77 commit fa0229e
Copy full SHA for fa0229e

File tree

Expand file treeCollapse file tree

2 files changed

+14
-40
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-40
lines changed

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+12-6Lines 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='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

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+2-34Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.