|
1 | 1 | """ |
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*. |
3 | 3 |
|
4 | 4 | *RGB* and *RGBA* are sequences of, respectively, 3 or 4 floats in the |
5 | 5 | range 0-1. |
|
26 | 26 | :doc:`/tutorials/colors/colormapnorms` for more details about data |
27 | 27 | normalization |
28 | 28 |
|
29 | | - More colormaps are available at palettable_ |
| 29 | + More colormaps are available at palettable_. |
30 | 30 |
|
31 | 31 | The module also provides functions for checking whether an object can be |
32 | 32 | interpreted as a color (:func:`is_color_like`), for converting such an object |
|
37 | 37 | Matplotlib recognizes the following formats to specify a color: |
38 | 38 |
|
39 | 39 | * 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); |
42 | 43 | * a string representation of a float value in ``[0, 1]`` inclusive for gray |
43 | 44 | level (e.g., ``'0.5'``); |
44 | 45 | * 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); |
52 | 53 | * a "CN" color spec, i.e. `'C'` followed by a number, which is an index into |
53 | 54 | the default property cycle (``matplotlib.rcParams['axes.prop_cycle']``); the |
54 | 55 | indexing is intended to occur at rendering time, and defaults to black if the |
55 | 56 | cycle does not include color. |
56 | 57 |
|
57 | | -All string specifications of color, other than "CN", are case-insensitive. |
58 | | -
|
59 | 58 | .. _palettable: https://jiffyclub.github.io/palettable/ |
60 | | -
|
| 59 | +.. _xkcd color survey: https://xkcd.com/color/rgb/ |
61 | 60 | """ |
62 | 61 |
|
63 | 62 | from collections.abc import Sized |
@@ -201,10 +200,12 @@ def _to_rgba_no_colorcycle(c, alpha=None): |
201 | 200 | except KeyError: |
202 | 201 | pass |
203 | 202 | 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.") |
208 | 209 | if isinstance(c, str): |
209 | 210 | # hex color with no alpha. |
210 | 211 | match = re.match(r"\A#[a-fA-F0-9]{6}\Z", c) |
|
0 commit comments