Skip to content

Commit 07af129

Browse files
timhoffmmeeseeksmachine
authored andcommitted
Backport PR matplotlib#24434: Fix pyplot.figlegend docstring
1 parent 120221a commit 07af129

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/matplotlib/figure.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,9 +984,12 @@ def clf(self, keep_observers=False):
984984
"""
985985
return self.clear(keep_observers=keep_observers)
986986

987-
# Note: in the docstring below, the newlines in the examples after the
988-
# calls to legend() allow replacing it with figlegend() to generate the
989-
# docstring of pyplot.figlegend.
987+
# Note: the docstring below is modified with replace for the pyplot
988+
# version of this function because the method name differs (plt.figlegend)
989+
# the replacements are:
990+
# " legend(" -> " figlegend(" for the signatures
991+
# "fig.legend(" -> "plt.figlegend" for the code examples
992+
# "ax.plot" -> "plt.plot" for consistency in using pyplot when able
990993
@_docstring.dedent_interpd
991994
def legend(self, *args, **kwargs):
992995
"""

lib/matplotlib/pyplot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,10 @@ def savefig(*args, **kwargs):
962962
def figlegend(*args, **kwargs):
963963
return gcf().legend(*args, **kwargs)
964964
if Figure.legend.__doc__:
965-
figlegend.__doc__ = Figure.legend.__doc__.replace("legend(", "figlegend(")
965+
figlegend.__doc__ = Figure.legend.__doc__ \
966+
.replace(" legend(", " figlegend(") \
967+
.replace("fig.legend(", "plt.figlegend(") \
968+
.replace("ax.plot(", "plt.plot(")
966969

967970

968971
## Axes ##

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy