-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Undeprecate case-insensitive "long" colornames. #13376
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
Conversation
@@ -66,7 +66,7 @@ def setup(ax): | |||
# Index Locator | |||
ax = plt.subplot(n, 1, 5) | |||
setup(ax) | |||
ax.plot(range(0, 5), [0]*5, color='white') | |||
ax.plot(range(0, 5), [0]*5, color='White') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave basic color words lowercase, even though they are case-insensitive. Seems more natural and common.
https://www.w3.org/TR/css-color-3/ Section 4.1. Basic color keywords
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/matplotlib/colors.py
Outdated
or ``(0.1, 0.2, 0.5, 0.3)``); | ||
* a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0F0F0F0F'``); | ||
or ``(0.1, 0.2, 0.5, 0.3)``); | ||
* a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0f0f0f0f'``); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0f0f0f0f'``); | |
* a hex RGB or RGBA string (e.g., ``'#0f0f0f'`` or ``'#0f0f0f80'``); |
- I would not change the case when actually showcasing the difference between RGB and RGBA. That's distracting from the original purpose.
- I recommend to use a different value for alpha than the RGB values. While #0f0f0f is common it's unlikely that the alpha value would be the same, this makes the example more realistic and easier to understand. You may add an additional note that the string is case insensitive.
- [minor] I have a slight preference for lowercase hex color values. HTML5 specifies "valid simple color" and the specialization valid lowercase simple color - but not an uppercase simple color. This indicates that lowercase is more important, also it's the standard for serializing color values in HTML5. Another hint is that some random thread on RGB case mentions the lowercase variant twice as often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/matplotlib/colors.py
Outdated
"removed %(removal)s.") | ||
if len(c) == 1: | ||
cbook.warn_deprecated( | ||
"3.1", message="Support for case-insensitive " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"3.1", message="Support for case-insensitive " | |
"3.1", message="Support for uppercase " |
'+ Please use lowercase instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tutorials/colors/colors.py
Outdated
* a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0F0F0F0F'``); | ||
* an RGB or RGBA (red, green, blue, alpha) tuple of float values in ``[0, 1]`` | ||
(e.g., ``(0.1, 0.2, 0.5)`` or ``(0.1, 0.2, 0.5, 0.3)``); | ||
* a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0f0f0f0f'``); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
CSS colors are case-insensitive (and typically given in CamelCase in CSS) so making them case-sensitive seems less than optimal and likely causes some pointless churn. Revert some corresponding changes in examples. Only keep the deprecation for single-letter colors, which are likely rarely given in uppercase (`plt.plot([1, 2], "Yo")` never worked and no one ever complained) and for which the rationale given in the changelog (collision with data-kwarg keys) remains valid. Update the docs to explicitly mention case-sensitivity.
d11b55f
to
4d26d3f
Compare
CSS colors are case-insensitive (and typically given in CamelCase in
CSS) so making them case-sensitive seems less than optimal and likely
causes some pointless churn. Revert some corresponding changes in
examples.
Only keep the deprecation for single-letter colors, which are likely
rarely given in uppercase (
plt.plot([1, 2], "Yo")
never worked andno one ever complained) and for which the rationale given in the
changelog (collision with data-kwarg keys) remains valid.
Update the docs to explicitly mention case-sensitivity.
Partially reverts #13211; reverts #13227.
Sorry for the change of mind...
Milestoning as RC 3.1 to avoid the spurious deprecation warning.
PR Summary
PR Checklist