Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fc1f272

Browse filesBrowse files
authored
Merge pull request #13376 from anntzer/case-insensitive-colors
Undeprecate case-insensitive "long" colornames.
2 parents aab3e8a + 4d26d3f commit fc1f272
Copy full SHA for fc1f272

File tree

Expand file treeCollapse file tree

4 files changed

+38
-35
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+38
-35
lines changed

‎doc/api/next_api_changes/2019-01-19-AL.rst

Copy file name to clipboardExpand all lines: doc/api/next_api_changes/2019-01-19-AL.rst
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Deprecations
22
````````````
33

4-
Support for passing colors as UPPERCASE strings is deprecated; color names will
5-
become case-sensitive (all-lowercase) after the deprecation period has passed.
4+
Support for passing single-letter colors (one of "rgbcmykw") as UPPERCASE
5+
characters is deprecated; these colors will become case-sensitive (lowercase)
6+
after the deprecation period has passed.
67

78
The goal is to decrease the number of ambiguous cases when using the ``data``
89
keyword to plotting methods; e.g. ``plot("X", "Y", data={"X": ..., "Y": ...})``

‎examples/statistics/barchart_demo.py

Copy file name to clipboardExpand all lines: examples/statistics/barchart_demo.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
fig, ax = plt.subplots()
3030
rects1 = ax.bar(ind - width/2, men_means, width, yerr=men_std,
31-
color='skyblue', label='Men')
31+
color='SkyBlue', label='Men')
3232
rects2 = ax.bar(ind + width/2, women_means, width, yerr=women_std,
33-
color='indianred', label='Women')
33+
color='IndianRed', label='Women')
3434

3535
# Add some text for labels, title and custom x-axis tick labels, etc.
3636
ax.set_ylabel('Scores')

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+19-18Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
A module for converting numbers or color arguments to *RGB* or *RGBA*
2+
A module for converting numbers or color arguments to *RGB* or *RGBA*.
33
44
*RGB* and *RGBA* are sequences of, respectively, 3 or 4 floats in the
55
range 0-1.
@@ -26,7 +26,7 @@
2626
:doc:`/tutorials/colors/colormapnorms` for more details about data
2727
normalization
2828
29-
More colormaps are available at palettable_
29+
More colormaps are available at palettable_.
3030
3131
The module also provides functions for checking whether an object can be
3232
interpreted as a color (:func:`is_color_like`), for converting such an object
@@ -37,27 +37,26 @@
3737
Matplotlib recognizes the following formats to specify a color:
3838
3939
* an RGB or RGBA tuple of float values in ``[0, 1]`` (e.g., ``(0.1, 0.2, 0.5)``
40-
or ``(0.1, 0.2, 0.5, 0.3)``);
41-
* a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0F0F0F0F'``);
40+
or ``(0.1, 0.2, 0.5, 0.3)``);
41+
* a hex RGB or RGBA string (e.g., ``'#0f0f0f'`` or ``'#0f0f0f80'``;
42+
case-insensitive);
4243
* a string representation of a float value in ``[0, 1]`` inclusive for gray
4344
level (e.g., ``'0.5'``);
4445
* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``;
45-
* a X11/CSS4 color name;
46-
* a name from the `xkcd color survey <https://xkcd.com/color/rgb/>`__;
47-
prefixed with ``'xkcd:'`` (e.g., ``'xkcd:sky blue'``);
48-
* one of ``{'tab:blue', 'tab:orange', 'tab:green',
49-
'tab:red', 'tab:purple', 'tab:brown', 'tab:pink',
50-
'tab:gray', 'tab:olive', 'tab:cyan'}`` which are the Tableau Colors from the
51-
'T10' categorical palette (which is the default color cycle);
46+
* a X11/CSS4 color name (case-insensitive);
47+
* a name from the `xkcd color survey`_, prefixed with ``'xkcd:'`` (e.g.,
48+
``'xkcd:sky blue'``; case insensitive);
49+
* one of the Tableau Colors from the 'T10' categorical palette (the default
50+
color cycle): ``{'tab:blue', 'tab:orange', 'tab:green', 'tab:red',
51+
'tab:purple', 'tab:brown', 'tab:pink', 'tab:gray', 'tab:olive', 'tab:cyan'}``
52+
(case-insensitive);
5253
* a "CN" color spec, i.e. `'C'` followed by a number, which is an index into
5354
the default property cycle (``matplotlib.rcParams['axes.prop_cycle']``); the
5455
indexing is intended to occur at rendering time, and defaults to black if the
5556
cycle does not include color.
5657
57-
All string specifications of color, other than "CN", are case-insensitive.
58-
5958
.. _palettable: https://jiffyclub.github.io/palettable/
60-
59+
.. _xkcd color survey: https://xkcd.com/color/rgb/
6160
"""
6261

6362
from collections.abc import Sized
@@ -201,10 +200,12 @@ def _to_rgba_no_colorcycle(c, alpha=None):
201200
except KeyError:
202201
pass
203202
else:
204-
cbook.warn_deprecated(
205-
"3.1", message="Support for case-insensitive colors is "
206-
"deprecated since Matplotlib %(since)s and will be "
207-
"removed %(removal)s.")
203+
if len(orig_c) == 1:
204+
cbook.warn_deprecated(
205+
"3.1", message="Support for uppercase "
206+
"single-letter colors is deprecated since Matplotlib "
207+
"%(since)s and will be removed %(removal)s; please "
208+
"use lowercase instead.")
208209
if isinstance(c, str):
209210
# hex color with no alpha.
210211
match = re.match(r"\A#[a-fA-F0-9]{6}\Z", c)

‎tutorials/colors/colors.py

Copy file name to clipboardExpand all lines: tutorials/colors/colors.py
+14-13Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,28 @@
55
66
Matplotlib recognizes the following formats to specify a color:
77
8-
* an RGB or RGBA tuple of float values in ``[0, 1]`` (e.g., ``(0.1, 0.2, 0.5)``
9-
or ``(0.1, 0.2, 0.5, 0.3)``). RGBA is short for Red, Green, Blue, Alpha;
10-
* a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0F0F0F0F'``);
8+
* an RGB or RGBA (red, green, blue, alpha) tuple of float values in ``[0, 1]``
9+
(e.g., ``(0.1, 0.2, 0.5)`` or ``(0.1, 0.2, 0.5, 0.3)``);
10+
* a hex RGB or RGBA string (e.g., ``'#0f0f0f'`` or ``'#0f0f0f80'``;
11+
case-insensitive);
1112
* a string representation of a float value in ``[0, 1]`` inclusive for gray
1213
level (e.g., ``'0.5'``);
1314
* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``;
14-
* a X11/CSS4 color name;
15-
* a name from the `xkcd color survey <https://xkcd.com/color/rgb/>`__;
16-
prefixed with ``'xkcd:'`` (e.g., ``'xkcd:sky blue'``);
17-
* one of ``{'tab:blue', 'tab:orange', 'tab:green',
18-
'tab:red', 'tab:purple', 'tab:brown', 'tab:pink',
19-
'tab:gray', 'tab:olive', 'tab:cyan'}`` which are the Tableau Colors from the
20-
'T10' categorical palette (which is the default color cycle);
15+
* a X11/CSS4 color name (case-insensitive);
16+
* a name from the `xkcd color survey`_, prefixed with ``'xkcd:'`` (e.g.,
17+
``'xkcd:sky blue'``; case insensitive);
18+
* one of the Tableau Colors from the 'T10' categorical palette (the default
19+
color cycle): ``{'tab:blue', 'tab:orange', 'tab:green', 'tab:red',
20+
'tab:purple', 'tab:brown', 'tab:pink', 'tab:gray', 'tab:olive', 'tab:cyan'}``
21+
(case-insensitive);
2122
* a "CN" color spec, i.e. `'C'` followed by a number, which is an index into
2223
the default property cycle (``matplotlib.rcParams['axes.prop_cycle']``); the
2324
indexing is intended to occur at rendering time, and defaults to black if the
2425
cycle does not include color.
2526
26-
"Red", "Green" and "Blue", are the intensities of those colors, the combination
27+
.. _xkcd color survey: https://xkcd.com/color/rgb/
28+
29+
"Red", "Green", and "Blue" are the intensities of those colors, the combination
2730
of which span the colorspace.
2831
2932
How "Alpha" behaves depends on the ``zorder`` of the Artist. Higher
@@ -36,8 +39,6 @@
3639
of 1 means the old color is completely covered by the new Artist, Alpha of 0
3740
means that pixel of the Artist is transparent.
3841
39-
All string specifications of color, other than "CN", are case-insensitive.
40-
4142
For more information on colors in matplotlib see
4243
4344
* the :doc:`/gallery/color/color_demo` example;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.