|
3 | 3 | Specifying Colors
|
4 | 4 | *****************
|
5 | 5 |
|
6 |
| -In almost all places in matplotlib where a color can be specified by the user |
7 |
| -it can be provided as: |
8 |
| -
|
9 |
| -* an RGB or RGBA tuple of float values in ``[0, 1]`` |
10 |
| - (e.g., ``(0.1, 0.2, 0.5)`` or ``(0.1, 0.2, 0.5, 0.3)``) |
11 |
| -* a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0F0F0F0F'``) |
12 |
| -* a string representation of a float value in ``[0, 1]`` |
13 |
| - inclusive for gray level (e.g., ``'0.5'``) |
14 |
| -* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}`` |
15 |
| -* a X11/CSS4 color name |
16 |
| -* a name from the `xkcd color survey <https://xkcd.com/color/rgb/>`__ |
17 |
| - prefixed with ``'xkcd:'`` (e.g., ``'xkcd:sky blue'``) |
18 |
| -* one of ``{'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9'}`` |
| 6 | +Matplotlib recognizes the following formats to specify a color: |
| 7 | +
|
| 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)``); |
| 10 | +* a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0F0F0F0F'``); |
| 11 | +* a string representation of a float value in ``[0, 1]`` inclusive for gray |
| 12 | + level (e.g., ``'0.5'``); |
| 13 | +* 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'``); |
19 | 17 | * one of ``{'tab:blue', 'tab:orange', 'tab:green',
|
20 | 18 | 'tab:red', 'tab:purple', 'tab:brown', 'tab:pink',
|
21 | 19 | 'tab:gray', 'tab:olive', 'tab:cyan'}`` which are the Tableau Colors from the
|
22 |
| - 'T10' categorical palette (which is the default color cycle). |
| 20 | + 'T10' categorical palette (which is the default color cycle); |
| 21 | +* a "CN" color spec, i.e. `'C'` followed by a single digit, which is an index |
| 22 | + into the default property cycle (``matplotlib.rcParams['axes.prop_cycle']``); |
| 23 | + the indexing occurs at artist creation time and defaults to black if the |
| 24 | + cycle does not include color. |
23 | 25 |
|
24 |
| -All string specifications of color are case-insensitive. |
| 26 | +All string specifications of color, other than "CN", are case-insensitive. |
25 | 27 |
|
| 28 | +"CN" color selection |
| 29 | +-------------------- |
26 | 30 |
|
27 |
| -``'CN'`` color selection |
28 |
| ------------------------- |
29 |
| -
|
30 |
| -Color can be specified by a string matching the regex ``C[0-9]``. |
31 |
| -This can be passed any place that a color is currently accepted and |
32 |
| -can be used as a 'single character color' in format-string to |
33 |
| -`matplotlib.Axes.plot`. |
34 |
| -
|
35 |
| -The single digit is the index into the default property cycle |
36 |
| -(``matplotlib.rcParams['axes.prop_cycle']``). If the property cycle does not |
37 |
| -include ``'color'`` then black is returned. The color is evaluated when the |
38 |
| -artist is created. For example, |
| 31 | +"CN" colors are converted to RGBA as soon as the artist is created. For |
| 32 | +example, |
39 | 33 | """
|
40 | 34 |
|
41 | 35 |
|
|
0 commit comments