Skip to content
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
Backport PR #24434: Fix pyplot.figlegend docstring
  • Loading branch information
timhoffm authored and meeseeksmachine committed Nov 15, 2022
commit 07af129bbb23d8155b45d38c9278bd27c36167c1
9 changes: 6 additions & 3 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,12 @@ def clf(self, keep_observers=False):
"""
return self.clear(keep_observers=keep_observers)

# 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.
# Note: the docstring below is modified with replace for the pyplot
# version of this function because the method name differs (plt.figlegend)
# the replacements are:
# " legend(" -> " figlegend(" for the signatures
# "fig.legend(" -> "plt.figlegend" for the code examples
# "ax.plot" -> "plt.plot" for consistency in using pyplot when able
@_docstring.dedent_interpd
def legend(self, *args, **kwargs):
"""
Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,10 @@ def savefig(*args, **kwargs):
def figlegend(*args, **kwargs):
return gcf().legend(*args, **kwargs)
if Figure.legend.__doc__:
figlegend.__doc__ = Figure.legend.__doc__.replace("legend(", "figlegend(")
figlegend.__doc__ = Figure.legend.__doc__ \
.replace(" legend(", " figlegend(") \
.replace("fig.legend(", "plt.figlegend(") \
.replace("ax.plot(", "plt.plot(")


## Axes ##
Expand Down