FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

FIX: correctly handle ax.legend(..., legendcolor='none') by tacaswell · Pull Request #20225 · matplotlib/matplotlib · GitHub

Repository navigation

FIX: correctly handle ax.legend(..., legendcolor='none') - #20225

Merged
QuLogic merged 1 commit into
matplotlib:masterfrom
tacaswell:fix_legend_labelcolor_none
May 15, 2021
Merged

QuLogic merged 1 commit into
matplotlib:masterfrom
tacaswell:fix_legend_labelcolor_none

Conversation

Copy link
Copy Markdown
Member

PR Summary

Previously this would result in the label color being ignored because
colors.to_rgba_array('none') results in a 0 length array which in turn has
a 0 length cycle, which results in the zip over texts and colors terminating
before we have touched any of the texts, ignoring the color.

This makes::

 ax.legend(..., legendcolor='none')
 ax.legend(..., legendcolor=['none'])

behave the same

Discovered this while reviewing #20084 and trying to demonstrate the difference between None and 'none' in our color conventions.

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • [N/A] New features are documented, with examples if plot related.
  • [N/A] 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).
  • [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).

Previously this would result in the label color being ignored because
colors.to_rgba_array('none') results in a 0 length array which in turn has
a 0 length cycle, which results in the zip over texts and colors terminating
before we have touched any of the texts, ignoring the color.

This makes::

     ax.legend(..., legendcolor='none')
     ax.legend(..., legendcolor=['none'])

behave the same
tacaswell added this to the v3.4.3 milestone May 14, 2021
Comment thread lib/matplotlib/legend.py
break
except AttributeError:
pass
elif isinstance(labelcolor, str) and labelcolor == 'none':

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I guess I'd have thought these were redundant....

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If a numpy array come is than elif obj == "none": gets us the "ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()" issue.

I thought about merging this with the conditional above, but was trying to avoid causing a rebase for @Carloscerq in #20084.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Don’t worry about it. I think I can handle it over the weekend, and, if it’s the case, I can remake the #20084 .

QuLogic merged commit c50a374 into matplotlib:master May 15, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request May 15, 2021
QuLogic added a commit that referenced this pull request May 15, 2021
…225-on-v3.4.x

Backport PR #20225 on branch v3.4.x (FIX: correctly handle ax.legend(..., legendcolor='none'))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL