-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
[ENH]: axes.labelcolor should use text.color by default #28155
Comments
Hi @anntzer, would it make sense to provide support for "auto" in --- a/lib/matplotlib/text.py
+++ b/lib/matplotlib/text.py
@@ -987,11 +987,11 @@ class Text(Artist):
----------
color : :mpltype:`color`
"""
- # "auto" is only supported by axisartist, but we can just let it error
- # out at draw time for simplicity.
- if not cbook._str_equal(color, "auto"):
- mpl.colors._check_color_like(color=color)
- self._color = color
+ if color == None or cbook._str_lower_equal(color, "auto"):
+ self._color = mpl.rcParams["text.color"]
+ else:
+ self._color = color
+ mpl.colors._check_color_like(color=color)
self.stale = True |
I think normal matplotlib semantics would be to just support None. |
I wanted to ask before I created a PR, since my current solution adds a bunch of checks in various parts of the code like this: if not cbook._str_lower_equal(mpl.rcParams['axes.labelcolor'], 'auto'):
self.label.set_color(mpl.rcParams['axes.labelcolor'])
else:
self.label.set_color(mpl.rcParams['text.color']) Whereas, supporting |
Problem
rcParams["axes.titlecolor"] defaults to "auto", i.e. use text.color. On the other hand rcParams["axes.labelcolor"] (the color of the x/ylabels) defaults to "black", i.e. changing rcParams["text.color"] doesn't affect these labels).
Proposed solution
Add support for rcParams["axes.labelcolor"] = "auto", meaning to use the default text color, and make that the default rc value.
For bonus points: rcParams["x/ytick.labelcolor"] currently defaults to "inherit", which means to use the tick color. If we change here the spelling of "use the fallback" to "auto" (#28154), we could use that to also make "auto" mean "use rcParams["text.default"]" instead of rcParams["xtick.color"], which seems actually more consistent, especially if we also switch the rcParams["x/ytick.color"] to defaulting to the defaulf spines color (rcParams["axes.edgecolor"]) -- again, making the tick colors match the spine colors seems more important, to me, than making the tick colors and the ticklabel colors match by default, but ymmv.
The text was updated successfully, but these errors were encountered: