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 149eb61

Browse filesBrowse files
committed
Update color docs.
1 parent df6acf9 commit 149eb61
Copy full SHA for 149eb61

File tree

Expand file treeCollapse file tree

3 files changed

+43
-60
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+43
-60
lines changed

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+21-33Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,27 @@
2121
`#rrggbb` format (:func:`to_hex`), and a sequence of colors to an `(n, 4)`
2222
RGBA array (:func:`to_rgba_array`). Caching is used for efficiency.
2323
24-
Commands which take color arguments can use several formats to specify
25-
the colors. For the basic built-in colors, you can use a single letter
26-
27-
- `b`: blue
28-
- `g`: green
29-
- `r`: red
30-
- `c`: cyan
31-
- `m`: magenta
32-
- `y`: yellow
33-
- `k`: black
34-
- `w`: white
35-
36-
To use the colors that are part of the active color cycle in the current style,
37-
use `C` followed by a digit. For example:
38-
39-
- `C0`: The first color in the cycle
40-
- `C1`: The second color in the cycle
41-
42-
Gray shades can be given as a string encoding a float in the 0-1 range, e.g.::
43-
44-
color = '0.75'
45-
46-
For a greater range of colors, you have two options. You can specify the
47-
color using an html hex string, as in::
48-
49-
color = '#eeefff'
50-
51-
(possibly specifying an alpha value as well), or you can pass an `(r, g, b)`
52-
or `(r, g, b, a)` tuple, where each of `r`, `g`, `b` and `a` are in the range
53-
[0,1].
54-
55-
Finally, legal html names for colors, like 'red', 'burlywood' and 'chartreuse'
56-
are supported.
24+
Matplotlib recognizes the following formats to specify a color:
25+
26+
* an RGB or RGBA tuple of float values in ``[0, 1]`` (e.g., ``(0.1, 0.2, 0.5)``
27+
or ``(0.1, 0.2, 0.5, 0.3)``);
28+
* a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0F0F0F0F'``);
29+
* a string representation of a float value in ``[0, 1]`` inclusive for gray
30+
level (e.g., ``'0.5'``);
31+
* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``;
32+
* a X11/CSS4 color name;
33+
* a name from the `xkcd color survey <https://xkcd.com/color/rgb/>`__;
34+
prefixed with ``'xkcd:'`` (e.g., ``'xkcd:sky blue'``);
35+
* one of ``{'tab:blue', 'tab:orange', 'tab:green',
36+
'tab:red', 'tab:purple', 'tab:brown', 'tab:pink',
37+
'tab:gray', 'tab:olive', 'tab:cyan'}`` which are the Tableau Colors from the
38+
'T10' categorical palette (which is the default color cycle);
39+
* a "CN" color spec, i.e. `'C'` followed by a single digit, which is an index
40+
into the default property cycle (``matplotlib.rcParams['axes.prop_cycle']``);
41+
the indexing occurs at artist creation time and defaults to black if the
42+
cycle does not include color.
43+
44+
All string specifications of color, other than "CN", are case-insensitive.
5745
"""
5846

5947
from __future__ import (absolute_import, division, print_function,

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,7 @@ def get_plot_commands():
18331833
return sorted(commands)
18341834

18351835

1836+
@deprecated('2.1')
18361837
def colors():
18371838
"""
18381839
This is a do-nothing function to provide you with help on how

‎tutorials/colors/colors.py

Copy file name to clipboardExpand all lines: tutorials/colors/colors.py
+21-27Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,33 @@
33
Specifying Colors
44
*****************
55
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'``);
1917
* one of ``{'tab:blue', 'tab:orange', 'tab:green',
2018
'tab:red', 'tab:purple', 'tab:brown', 'tab:pink',
2119
'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.
2325
24-
All string specifications of color are case-insensitive.
26+
All string specifications of color, other than "CN", are case-insensitive.
2527
28+
"CN" color selection
29+
--------------------
2630
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,
3933
"""
4034

4135

0 commit comments

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