8000 Documentation of new shorthand hex color specification. · matplotlib/matplotlib@790756f · GitHub
[go: up one dir, main page]

Skip to content

Commit 790756f

Browse files
Patrick FeiringPatrick Feiring
authored andcommitted
Documentation of new shorthand hex color specification.
1 parent 72e4f86 commit 790756f

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
3-digit and 4-digit hex colors
2+
------------------------------
3+
4+
Colors can now be specified using 3-digit or 4-digit hex colors, shorthand for
5+
the colors obtained by duplicating each character, e.g. ``#123`` is equivalent to
6+
``#112233`` and ``#123a`` is equivalent to ``#112233aa``.

lib/matplotlib/colors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
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);
43+
* a shorthand hex RGB or RGBA string, equivalent to the hex RGB or RGBA
44+
string obtained by duplicating each character, (e.g., ``'#abc'``, equivalent
45+
to ``'#aabbcc'``, or ``'#abcd'``, equivalent to ``'#aabbccdd'``;
46+
case-insensitive);
4347
* a string representation of a float value in ``[0, 1]`` inclusive for gray
4448
level (e.g., ``'0.5'``);
4549
* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``, they are the single

tutorials/colors/colors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
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);
12+
* a shorthand hex RGB or RGBA string, equivalent to the hex RGB or RGBA
13+
string obtained by duplicating each character, (e.g., ``'#abc'``, equivalent
14+
to ``'#aabbcc'``, or ``'#abcd'``, equivalent to ``'#aabbccdd'``;
15+
case-insensitive);
1216
* a string representation of a float value in ``[0, 1]`` inclusive for gray
1317
level (e.g., ``'0.5'``);
1418
* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``, they are the single

0 commit comments

Comments
 (0)
0