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 18
18
from numpy .testing .utils import assert_array_equal , assert_array_almost_equal
19
19
from nose .plugins .skip import SkipTest
20
20
21
- from cycler import cycler
21
+ from matplotlib import cycler
22
22
import matplotlib
23
23
import matplotlib .colors as mcolors
24
24
import matplotlib .cm as cm
@@ -615,6 +615,14 @@ def test_cn():
615
615
assert mcolors .to_hex ("C0" ) == '#0343df'
616
616
assert mcolors .to_hex ("C1" ) == '#ff0000'
617
617
618
+ matplotlib .rcParams ['axes.prop_cycle' ] = cycler ('color' , ['8e4585' , 'r' ])
619
+
620
+ assert mcolors .to_hex ("C0" ) == '#8e4585'
621
+ # if '8e4585' gets parsed as a float before it gets detected as a hex
622
+ # colour it will be interpreted as a very large number.
623
+ # this mustn't happen.
624
+ assert mcolors .to_rgb ("C0" )[0 ] != np .inf
625
+
618
626
619
627
def test_conversions ():
620
628
# to_rgba_array("none") returns a (0, 4) array.
You can’t perform that action at this time.
0 commit comments