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

Skip to content

Commit 513b0fc

Browse files
authored
Merge pull request #24458 from meeseeksmachine/auto-backport-of-pr-24434-on-v3.6.x
Backport PR #24434 on branch v3.6.x (Fix pyplot.figlegend docstring)
2 parents 120221a + 07af129 commit 513b0fc

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)