File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -312,10 +312,11 @@ def validate_color(s):
312
312
if isinstance (s , str ):
313
313
if s .lower () == 'none' :
314
314
return 'none'
315
- if len (s ) == 6 or len (s ) == 8 :
316
- stmp = '#' + s
317
- if is_color_like (stmp ):
318
- return stmp
315
+ # Support "rrggbb"/"rrggbbaa" without leading '#' as these would be
316
+ # interpreted as comments in matplotlibrc. Note that "rgb" -> "#rgb"
317
+ # is explicitly not supported, because of the ambiguity e.g. in "C10".
318
+ if len (s ) in [6 , 8 ] and {* s .lower ()} <= {* "0123456789abcdef" }:
319
+ return f'#{ s } '
319
320
320
321
if is_color_like (s ):
321
322
return s
Original file line number Diff line number Diff line change 14
14
+--------------------------------------+--------------------------------------+
15
15
| Case-insensitive hex RGB or RGBA | - ``'#0f0f0f'`` |
16
16
| string. | - ``'#0f0f0f80'`` |
17
+ | | |
18
+ | .. note:: | |
19
+ | In a matplotlibrc file, and only | |
20
+ | there, these strings must be | |
21
+ | given without the leading '#', | |
22
+ | e.g. as ``text.color: 0f0f0f``. | |
17
23
+--------------------------------------+--------------------------------------+
18
24
| Case-insensitive RGB or RGBA string | - ``'#abc'`` as ``'#aabbcc'`` |
19
25
| equivalent hex shorthand of | - ``'#fb1'`` as ``'#ffbb11'`` |
You can’t perform that action at this time.
0 commit comments