Skip to content
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

DOC: Highlight information about avoiding labels in legend #23673

Merged
merged 1 commit into from
Aug 19, 2022

Conversation

oscargus
Copy link
Contributor

@oscargus oscargus commented Aug 19, 2022

PR Summary

Related to the recent discussion about duplicate labels #23664 and SO-questions like:
https://stackoverflow.com/questions/13588920/stop-matplotlib-repeating-labels-in-legend (63k views)
https://stackoverflow.com/questions/19385639/duplicate-items-in-legend-in-matplotlib (47k views)

and especially the comment:

As the [docs](http://matplotlib.org/users/legend_guide.html) say, although it's easy to miss:

If label attribute is empty string or starts with “_”, those artists will be ignored.

Maybe this PR won't make all questions go away, but can still be worth highlighting this.

PR Checklist

Tests and Styling

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

Documentation

  • [N/A] New features are documented, with examples if plot related.
  • [N/A] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@oscargus oscargus added this to the v3.6.0 milestone Aug 19, 2022
@oscargus oscargus changed the title Highlight information about avoiding labels in legend DOC: Highlight information about avoiding labels in legend Aug 19, 2022
Copy link
Member

@story645 story645 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I very much like the doc improvements to make this clearer. 😁

lib/matplotlib/axes/_axes.py Outdated Show resolved Hide resolved
lib/matplotlib/axes/_axes.py Outdated Show resolved Hide resolved
tutorials/intermediate/legend_guide.py Outdated Show resolved Hide resolved
@oscargus
Copy link
Contributor Author

I've adapted the suggestions (as committing directly lead to too long lines). Thanks!

@tacaswell tacaswell merged commit 6dee4f5 into matplotlib:main Aug 19, 2022
@oscargus oscargus deleted the legenddocs branch August 19, 2022 21:57
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.

None yet

4 participants