Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b34895d

Browse files
authored
Merge pull request #14718 from bingyao/more_explicit_colors_names
Add explanations for single character color names.
2 parents 1a0a0bf + 9da2435 commit b34895d

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

lib/matplotlib/_color_data.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33

44
BASE_COLORS = {
5-
'b': (0, 0, 1),
6-
'g': (0, 0.5, 0),
7-
'r': (1, 0, 0),
8-
'c': (0, 0.75, 0.75),
9-
'm': (0.75, 0, 0.75),
10-
'y': (0.75, 0.75, 0),
11-
'k': (0, 0, 0),
12-
'w': (1, 1, 1)}
5+
'b': (0, 0, 1), # blue
6+
'g': (0, 0.5, 0), # green
7+
'r': (1, 0, 0), # red
8+
'c': (0, 0.75, 0.75), # cyan
9+
'm': (0.75, 0, 0.75), # magenta
10+
'y': (0.75, 0.75, 0), # yellow
11+
'k': (0, 0, 0), # black
12+
'w': (1, 1, 1), # white
13+
}
1314

1415

1516
# These colors are from Tableau
@@ -32,8 +33,10 @@
3233

3334
# This mapping of color names -> hex values is taken from
3435
# a survey run by Randall Munroe see:
35-
# http://blog.xkcd.com/2010/05/03/color-survey-results/
36+
# https://blog.xkcd.com/2010/05/03/color-survey-results/
3637
# for more details. The results are hosted at
38+
# https://xkcd.com/color/rgb
39+
# and also available as a text file at
3740
# https://xkcd.com/color/rgb.txt
3841
#
3942
# License: http://creativecommons.org/publicdomain/zero/1.0/

lib/matplotlib/colors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@
3636
3737
Matplotlib recognizes the following formats to specify a color:
3838
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)``);
39+
* an RGB or RGBA (red, green, blue, alpha) tuple of float values in closed
40+
interval ``[0, 1]`` (e.g., ``(0.1, 0.2, 0.5)`` or ``(0.1, 0.2, 0.5, 0.3)``);
4141
* a hex RGB or RGBA string (e.g., ``'#0f0f0f'`` or ``'#0f0f0f80'``;
4242
case-insensitive);
4343
* a string representation of a float value in ``[0, 1]`` inclusive for gray
4444
level (e.g., ``'0.5'``);
45-
* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``;
45+
* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``, they are the single
46+
character short-hand notations for blue, green, red, cyan, magenta, yellow,
47+
black, and white.
4648
* a X11/CSS4 color name (case-insensitive);
4749
* a name from the `xkcd color survey`_, prefixed with ``'xkcd:'`` (e.g.,
4850
``'xkcd:sky blue'``; case insensitive);

tutorials/colors/colors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
66
Matplotlib recognizes the following formats to specify a color:
77
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)``);
8+
* an RGB or RGBA (red, green, blue, alpha) tuple of float values in closed
9+
interval ``[0, 1]`` (e.g., ``(0.1, 0.2, 0.5)`` or ``(0.1, 0.2, 0.5, 0.3)``);
1010
* a hex RGB or RGBA string (e.g., ``'#0f0f0f'`` or ``'#0f0f0f80'``;
1111
case-insensitive);
1212
* a string representation of a float value in ``[0, 1]`` inclusive for gray
1313
level (e.g., ``'0.5'``);
14-
* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``;
14+
* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``, they are the single
15+
character short-hand notations for blue, green, red, cyan, magenta, yellow,
16+
black, and white.
1517
* a X11/CSS4 color name (case-insensitive);
1618
* a name from the `xkcd color survey`_, prefixed with ``'xkcd:'`` (e.g.,
1719
``'xkcd:sky blue'``; case insensitive);

0 commit comments

Comments
 (0)