From b31a7bad383b47a5c2f9e8d8e1b25eee738ca68e Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 10 Jul 2020 16:02:47 -0400 Subject: [PATCH] Backport PR #17871: Mention single char colors shading in more places --- examples/color/color_demo.py | 26 +++++++++++++++----------- lib/matplotlib/colors.py | 8 +++++--- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/examples/color/color_demo.py b/examples/color/color_demo.py index 40a0e926b8dd..0ad1c11edfa9 100644 --- a/examples/color/color_demo.py +++ b/examples/color/color_demo.py @@ -6,23 +6,27 @@ Matplotlib recognizes the following formats to specify a color: 1) an RGB or RGBA tuple of float values in ``[0, 1]`` (e.g. ``(0.1, 0.2, 0.5)`` - or ``(0.1, 0.2, 0.5, 0.3)``). RGBA is short for Red, Green, Blue, Alpha; + or ``(0.1, 0.2, 0.5, 0.3)``). RGBA is short for Red, Green, Blue, Alpha; 2) a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0F0F0F0F'``); -3) a string representation of a float value in ``[0, 1]`` inclusive for gray +3) a shorthand hex RGB or RGBA string, equivalent to the hex RGB or RGBA + string obtained by duplicating each character, (e.g., ``'#abc'``, equivalent + to ``'#aabbcc'``, or ``'#abcd'``, equivalent to ``'#aabbccdd'``); +4) a string representation of a float value in ``[0, 1]`` inclusive for gray level (e.g., ``'0.5'``); -4) a single letter string, i.e. one of - ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``; -5) a X11/CSS4 ("html") color name, e.g. ``"blue"``; -6) a name from the `xkcd color survey `__, +5) a single letter string, i.e. one of + ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``, which are short-hand notations + for shades of blue, green, red, cyan, magenta, yellow, black, and white; +6) a X11/CSS4 ("html") color name, e.g. ``"blue"``; +7) a name from the `xkcd color survey `__, prefixed with ``'xkcd:'`` (e.g., ``'xkcd:sky blue'``); -7) a "Cn" color spec, i.e. ``'C'`` followed by a number, which is an index into +8) a "Cn" color spec, i.e. ``'C'`` followed by a number, which is an index into the default property cycle (:rc:`axes.prop_cycle`); the indexing is intended to occur at rendering time, and defaults to black if the cycle does not include color. -8) one of ``{'tab:blue', 'tab:orange', 'tab:green', - 'tab:red', 'tab:purple', 'tab:brown', 'tab:pink', - 'tab:gray', 'tab:olive', 'tab:cyan'}`` which are the Tableau Colors from the - 'tab10' categorical palette (which is the default color cycle); +9) one of ``{'tab:blue', 'tab:orange', 'tab:green', 'tab:red', 'tab:purple', + 'tab:brown', 'tab:pink', 'tab:gray', 'tab:olive', 'tab:cyan'}`` which are + the Tableau Colors from the 'tab10' categorical palette (which is the + default color cycle); For more information on colors in matplotlib see diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index b1e76e27175b..2471c8a9698c 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -44,9 +44,11 @@ case-insensitive); * a string representation of a float value in ``[0, 1]`` inclusive for gray level (e.g., ``'0.5'``); -* one of ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``, they are the single - character short-hand notations for blue, green, red, cyan, magenta, yellow, - black, and white. +* one of the characters ``{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}``, which + are short-hand notations for shades of blue, green, red, cyan, magenta, + yellow, black, and white. Note that the colors ``'g', 'c', 'm', 'y'`` do not + coincide with the X11/CSS4 colors. Their particular shades were chosen for + better visibility of colored lines against typical backgrounds. * a X11/CSS4 color name (case-insensitive); * a name from the `xkcd color survey`_, prefixed with ``'xkcd:'`` (e.g., ``'xkcd:sky blue'``; case insensitive);