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

Skip to content

Fix pyplot.figlegend docstring #24434

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
Nov 15, 2022
Merged

Conversation

ksunden
Copy link
Member

@ksunden ksunden commented Nov 12, 2022

Closes #24433

PR Summary

The method name for Figure.legend in pyplot is figlegend due to a name collision.
As such, a .replace call is used to translate the docstring from the one written for Figure.legend to make sense for users interacting with plt.figlegend.

This behavior was originally introduced in #11975, using legend( alone (with no dotted name).

The docstring was updated in #18106, with additional examples that used fig.legend( in additional examples.
These new examples were caught by the replace and became fig.figlegend(.

This PR makes all calls fig.legend and simply removes the dot for the replace call.
This leads to some slightly incongrous examples which are using the object based api to call ax.plot but following that with figlegend from pyplot. (not wrong per se, but mixing APIs)
This was chosen as a compromise to allow the docstring to have one cannonical form, while still using the method name where help is called.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

@ksunden
Copy link
Member Author

ksunden commented Nov 12, 2022

We could be slightly more explicit by using plt.figlegend in the replace

@timhoffm timhoffm added this to the v3.6.3 milestone Nov 15, 2022
@timhoffm timhoffm merged commit d09526f into matplotlib:main Nov 15, 2022
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Nov 15, 2022
@ksunden ksunden deleted the figlegend_plt branch November 15, 2022 07:54
QuLogic added a commit that referenced this pull request Nov 15, 2022
…434-on-v3.6.x

Backport PR #24434 on branch v3.6.x (Fix pyplot.figlegend docstring)
@ksunden ksunden mentioned this pull request Feb 20, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Doc]: figlegend examples call fig.figlegend instead of plt.figlegend or fig.legend
3 participants