Skip to content

Legend edgecolor face #20265

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 2 commits into from
May 20, 2021
Merged

Conversation

efiring
Copy link
Member

@efiring efiring commented May 19, 2021

PR Summary

Simplify the legend handler for PolyCollection.

Alternative to #20260; closes #20258.

PR Checklist

  • [x ] Has pytest style unit tests (and pytest passes).
  • [ x] Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@efiring
Copy link
Member Author

efiring commented May 19, 2021

It looks like Azure is glitching on two jobs. I presume there must be a way to stop and restart them, but I haven't been able to find it.

@efiring efiring requested review from jklymak and QuLogic May 19, 2021 22:12

# orig_handle is a PolyCollection and legend_handle is a Patch.
# Directly set Patch color attributes (must be RGBA tuples).
legend_handle._facecolor = first_color(orig_handle.get_facecolor())
Copy link
Member

Choose a reason for hiding this comment

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

This is more invasive than my change so a couple of questions. 1) why set directly? 2) does this cover more cases, in which case should we add more tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. We want all the special-case handling to be done by the PolyCollection, after which we simply hand off the results to the Patch. See https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/patches.py#L249 for another example of this approach.
  2. I don't know. I think it is more a question of whether enough legend with/without hatching cases are tested than of any expected changes in behavior.
    More invasive? You could describe it that way, but I view it as a cleanup and an overall simplification.

@jklymak jklymak mentioned this pull request May 19, 2021
7 tasks
@QuLogic QuLogic added this to the v3.4.3 milestone May 20, 2021
@QuLogic QuLogic merged commit fa3c4fe into matplotlib:master May 20, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request May 20, 2021
jklymak added a commit that referenced this pull request May 20, 2021
…265-on-v3.4.x

Backport PR #20265 on branch v3.4.x (Legend edgecolor face)
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.

Using edgecolors='face' with stackplot causes value error when using plt.legend()
4 participants