Repository navigation
Add legend.labelcolor in rcParams - #20084
Conversation
There was a problem hiding this comment.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
|
Thanks for working on this! Overall 👍, but is it possible to have the default rcParam be None? Currently the default label color will fall back to the |
|
Sure. I think that making a little change in the lib/matplotlib/legend.py it can work. I will give it a try. |
| if labelcolor is None: | ||
| pass | ||
| elif isinstance(labelcolor, str) and labelcolor in color_getters: | ||
| if mpl.rcParams['legend.labelcolor'] != 'none': |
There was a problem hiding this comment.
The legend docstring should note that this rcparam exists....
There was a problem hiding this comment.
Should this be `
| if mpl.rcParams['legend.labelcolor'] != 'none': | |
| if mpl.rcParams['legend.labelcolor'] is not None: |
along with similar changes to validator? There are a number of places where we use the string 'none' as a color to mean "this thing does not get a color" and None (the singleton) to mean "use the default color".
That said, currently doing
...
ax.legend(labelcolor='none')
does not result in an invisible label which is a bug in the implementation below (cycle of a 0 length thing is also 0 length, not infinite).
There was a problem hiding this comment.
The rcParam can't be able to both be None and 'none', though, right? The fallback version would need a special value to work, like 'auto' or 'textcolor'?
| 'markerfacecolor' (or 'mfc'), or 'markeredgecolor' (or 'mec'). | ||
|
|
||
| Otherly, labelcolor can be set globally using :rc:`legend.labelcolor`. | ||
|
|
There was a problem hiding this comment.
Sorry to be picky, bit this should go in as
labelcolor : str or list, default: :rc:`legend.labelcolor`.
There was a problem hiding this comment.
Thanks for the review.
But when the rcParams[legend.labelcolor] is None(the default value(, should the docs say that it just uses the rcParams['text.color'] value?
There was a problem hiding this comment.
I think that should be specified in the description of the parameter if it is not already
There was a problem hiding this comment.
This is fine w/ me now. @tacaswell you have a block on this...
tacaswell
left a comment
There was a problem hiding this comment.
Looks on the right path, but the default value should be None not 'none'.
| if labelcolor is None: | ||
| pass | ||
| elif isinstance(labelcolor, str) and labelcolor in color_getters: | ||
| if mpl.rcParams['legend.labelcolor'] != 'none': |
There was a problem hiding this comment.
Should this be `
| if mpl.rcParams['legend.labelcolor'] != 'none': | |
| if mpl.rcParams['legend.labelcolor'] is not None: |
along with similar changes to validator? There are a number of places where we use the string 'none' as a color to mean "this thing does not get a color" and None (the singleton) to mean "use the default color".
That said, currently doing
...
ax.legend(labelcolor='none')
does not result in an invisible label which is a bug in the implementation below (cycle of a 0 length thing is also 0 length, not infinite).
|
@tacaswell you are still blocking on this.... |
|
Thanks @Carloscerq ! Congratulations on your first merged Matplotlib PR 🎉 hope we hear from you again! |
PR Summary
This is a proposal for a new
legendrcParam.The
legend.labelcolorwas proposed in #20049. It's for changing thelabelcolorof all figures(similar to the labelcolor ofplt.legend)Example:
PR Checklist
pytestpasses).flake8on changed files to check).flake8-docstringsand runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).