File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -367,12 +367,16 @@ def validate_color(s):
367
367
return 'None'
368
368
except AttributeError :
369
369
pass
370
+
371
+ if isinstance (s , six .string_types ):
372
+ if len (s ) == 6 or len (s ) == 8 :
373
+ stmp = '#' + s
374
+ if is_color_like (stmp ):
375
+ return stmp
376
+
370
377
if is_color_like (s ):
371
378
return s
372
- stmp = '#' + s
373
379
374
- if is_color_like (stmp ):
375
- return stmp
376
380
# If it is still valid, it must be a tuple.
377
381
colorarg = s
378
382
msg = ''
Original file line number Diff line number Diff line change 17
17
from numpy .testing .utils import assert_array_equal , assert_array_almost_equal
18
18
from nose .plugins .skip import SkipTest
19
19
20
- from cycler import cycler
20
+ from matplotlib import cycler
21
21
import matplotlib
22
22
import matplotlib .colors as mcolors
23
23
import matplotlib .cm as cm
@@ -602,6 +602,14 @@ def test_cn():
602
602
assert mcolors .to_hex ("C0" ) == '#0343df'
603
603
assert mcolors .to_hex ("C1" ) == '#ff0000'
604
604
605
+ matplotlib .rcParams ['axes.prop_cycle' ] = cycler ('color' , ['8e4585' , 'r' ])
606
+
607
+ assert mcolors .to_hex ("C0" ) == '#8e4585'
608
+ # if '8e4585' gets parsed as a float before it gets detected as a hex
609
+ # colour it will be interpreted as a very large number.
610
+ # this mustn't happen.
611
+ assert mcolors .to_rgb ("C0" )[0 ] != np .inf
612
+
605
613
606
614
def test_conversions ():
607
615
# to_rgba_array("none") returns a (0, 4) array.
You can’t perform that action at this time.
0 commit comments