Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Derive plt.figlegend.__doc__ from Figure.legend.__doc__. #11975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,10 @@ def get_axes(self):
"""
return self.axes

# Note: in the docstring below, the newlines in the examples after the
# calls to legend() allow replacing it with figlegend() to generate the
# docstring of pyplot.figlegend.

@docstring.dedent_interpd
def legend(self, *args, **kwargs):
"""
Expand All @@ -1691,15 +1695,17 @@ def legend(self, *args, **kwargs):

To make a legend for a list of lines and labels::

legend( (line1, line2, line3),
('label1', 'label2', 'label3'),
loc='upper right')
legend(
(line1, line2, line3),
('label1', 'label2', 'label3'),
loc='upper right')

These can also be specified by keyword::

legend(handles=(line1, line2, line3),
labels=('label1', 'label2', 'label3'),
loc='upper right')
legend(
handles=(line1, line2, line3),
labels=('label1', 'label2', 'label3'),
loc='upper right')

Parameters
----------
Expand Down
36 changes: 2 additions & 34 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,41 +756,9 @@ def figimage(*args, **kwargs):


def figlegend(*args, **kwargs):
"""
Place a legend in the figure.

*labels*
a sequence of strings

*handles*
a sequence of :class:`~matplotlib.lines.Line2D` or
:class:`~matplotlib.patches.Patch` instances

*loc*
can be a string or an integer specifying the legend
location

A :class:`matplotlib.legend.Legend` instance is returned.

Examples
--------

To make a legend from existing artists on every axes::

figlegend()

To make a legend for a list of lines and labels::

figlegend( (line1, line2, line3),
('label1', 'label2', 'label3'),
'upper right' )

.. seealso::

:func:`~matplotlib.pyplot.legend`

"""
return gcf().legend(*args, **kwargs)
if Figure.legend.__doc__:
figlegend.__doc__ = Figure.legend.__doc__.replace("legend(", "figlegend(")


## Axes ##
Expand Down