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

Skip to content

Commit 9a60729

Browse files
authored
Merge pull request #27905 from timhoffm/check-color-error-message
Improved error message for malformed colors
2 parents a198971 + 8083650 commit 9a60729

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/matplotlib/colors.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,14 @@ def _check_color_like(**kwargs):
243243
"""
244244
for k, v in kwargs.items():
245245
if not is_color_like(v):
246-
raise ValueError(f"{v!r} is not a valid value for {k}")
246+
raise ValueError(
247+
f"{v!r} is not a valid value for {k}: supported inputs are "
248+
f"(r, g, b) and (r, g, b, a) 0-1 float tuples; "
249+
f"'#rrggbb', '#rrggbbaa', '#rgb', '#rgba' strings; "
250+
f"named color strings; "
251+
f"string reprs of 0-1 floats for grayscale values; "
252+
f"'C0', 'C1', ... strings for colors of the color cycle; "
253+
f"and pairs combining one of the above with an alpha value")
247254

248255

249256
def same_color(c1, c2):

0 commit comments

Comments
 (0)