Skip to content

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

Merged
merged 1 commit into from
Feb 6, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 6, 2019

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.

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

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Feb 6, 2019
@anntzer anntzer added this to the v3.1.0 milestone Feb 6, 2019
@@ -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')
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

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'``);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

"removed %(removal)s.")
if len(c) == 1:
cbook.warn_deprecated(
"3.1", message="Support for case-insensitive "
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"3.1", message="Support for case-insensitive "
"3.1", message="Support for uppercase "

'+ Please use lowercase instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* 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'``);
Copy link
Member

Choose a reason for hiding this comment

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

see above.

Copy link
Contributor Author

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.
@timhoffm timhoffm merged commit fc1f272 into matplotlib:master Feb 6, 2019
@anntzer anntzer deleted the case-insensitive-colors branch February 7, 2019 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: color/color & colormaps
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants