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

Skip to content

Commit a26f9a3

Browse files
authored
Merge pull request #20336 from timhoffm/doc-module
Deduplicate color format specification
2 parents 944719e + 1a86a71 commit a26f9a3

File tree

3 files changed

+18
-41
lines changed

3 files changed

+18
-41
lines changed

lib/matplotlib/colors.py

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,8 @@
3232
"#rrggbb" format (`to_hex`), and a sequence of colors to an (n, 4)
3333
RGBA array (`to_rgba_array`). Caching is used for efficiency.
3434
35-
Matplotlib recognizes the following formats to specify a color:
36-
37-
* an RGB or RGBA (red, green, blue, alpha) tuple of float values in closed
38-
interval ``[0, 1]`` (e.g., ``(0.1, 0.2, 0.5)`` or ``(0.1, 0.2, 0.5, 0.3)``);
39-
* a hex RGB or RGBA string (e.g., ``'#0f0f0f'`` or ``'#0f0f0f80'``;
40-
case-insensitive);
41-
* a shorthand hex RGB or RGBA string, equivalent to the hex RGB or RGBA
42-
string obtained by duplicating each character, (e.g., ``'#abc'``, equivalent
43-
to ``'#aabbcc'``, or ``'#abcd'``, equivalent to ``'#aabbccdd'``;
44-
case-insensitive);
45-
* a string representation of a float value in ``[0, 1]`` inclusive for gray
46-
level (e.g., ``'0.5'``);
47-
* one of the characters ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``, which
48-
are short-hand notations for shades of blue, green, red, cyan, magenta,
49-
yellow, black, and white. Note that the colors ``'g', 'c', 'm', 'y'`` do not
50-
coincide with the X11/CSS4 colors. Their particular shades were chosen for
51-
better visibility of colored lines against typical backgrounds.
52-
* a X11/CSS4 color name (case-insensitive);
53-
* a name from the `xkcd color survey`_, prefixed with ``'xkcd:'`` (e.g.,
54-
``'xkcd:sky blue'``; case insensitive);
55-
* one of the Tableau Colors from the 'T10' categorical palette (the default
56-
color cycle): ``{'tab:blue', 'tab:orange', 'tab:green', 'tab:red',
57-
'tab:purple', 'tab:brown', 'tab:pink', 'tab:gray', 'tab:olive', 'tab:cyan'}``
58-
(case-insensitive);
59-
* a "CN" color spec, i.e. 'C' followed by a number, which is an index into the
60-
default property cycle (:rc:`axes.prop_cycle`); the indexing is intended to
61-
occur at rendering time, and defaults to black if the cycle does not include
62-
color.
35+
Colors that Matplotlib recognizes are listed at
36+
:doc:`/tutorials/colors/colors`.
6337
6438
.. _palettable: https://jiffyclub.github.io/palettable/
6539
.. _xkcd color survey: https://xkcd.com/color/rgb/

lib/matplotlib/legend_handler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
44
.. important::
55
6-
It is strongly encouraged to have read the :doc:`legend guide
7-
</tutorials/intermediate/legend_guide>` before this documentation.
6+
This is a low-level legend API, which most end users do not need.
7+
8+
We recommend that you are familiar with the :doc:`legend guide
9+
</tutorials/intermediate/legend_guide>` before reading this documentation.
810
911
Legend handlers are expected to be a callable object with a following
1012
signature. ::

tutorials/colors/colors.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
Specifying Colors
44
*****************
55
6-
Matplotlib recognizes the following formats in the table below to specify a
7-
color.
6+
Matplotlib recognizes the following formats to specify a color.
87
98
+--------------------------------------+--------------------------------------+
109
| Format | Example |
@@ -20,18 +19,20 @@
2019
| equivalent hex shorthand of | - ``'#fb1'`` as ``'#ffbb11'`` |
2120
| duplicated characters. | |
2221
+--------------------------------------+--------------------------------------+
23-
| String representation of float value | - ``'0.8'`` as light gray |
24-
| in closed interval ``[0, 1]`` for | - ``'0'`` as black |
25-
| black and white, respectively. | - ``'1'`` as white |
22+
| String representation of float value | - ``'0'`` as black |
23+
| in closed interval ``[0, 1]`` for | - ``'1'`` as white |
24+
| grayscale values. | - ``'0.8'`` as light gray |
2625
+--------------------------------------+--------------------------------------+
2726
| Single character shorthand notation | - ``'b'`` as blue |
28-
| for shades of colors. | - ``'g'`` as green |
27+
| for some basic colors. | - ``'g'`` as green |
2928
| | - ``'r'`` as red |
30-
| .. note:: The colors green, cyan, | - ``'c'`` as cyan |
31-
| magenta, and yellow do not | - ``'m'`` as magenta |
32-
| coincide with X11/CSS4 | - ``'y'`` as yellow |
33-
| colors. | - ``'k'`` as black |
34-
| | - ``'w'`` as white |
29+
| .. note:: | - ``'c'`` as cyan |
30+
| The colors green, cyan, magenta, | - ``'m'`` as magenta |
31+
| and yellow do not coincide with | - ``'y'`` as yellow |
32+
| X11/CSS4 colors. Their particular | - ``'k'`` as black |
33+
| shades were chosen for better | - ``'w'`` as white |
34+
| visibility of colored lines | |
35+
| against typical backgrounds. | |
3536
+--------------------------------------+--------------------------------------+
3637
| Case-insensitive X11/CSS4 color name | - ``'aquamarine'`` |
3738
| with no spaces. | - ``'mediumseagreen'`` |

0 commit comments

Comments
 (0)