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):
367367 return 'None'
368368 except AttributeError :
369369 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+
370377 if is_color_like (s ):
371378 return s
372- stmp = '#' + s
373379
374- if is_color_like (stmp ):
375- return stmp
376380 # If it is still valid, it must be a tuple.
377381 colorarg = s
378382 msg = ''
Original file line number Diff line number Diff line change 1717from numpy .testing .utils import assert_array_equal , assert_array_almost_equal
1818from nose .plugins .skip import SkipTest
1919
20- from cycler import cycler
20+ from matplotlib import cycler
2121import matplotlib
2222import matplotlib .colors as mcolors
2323import matplotlib .cm as cm
@@ -602,6 +602,14 @@ def test_cn():
602602 assert mcolors .to_hex ("C0" ) == '#0343df'
603603 assert mcolors .to_hex ("C1" ) == '#ff0000'
604604
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+
605613
606614def test_conversions ():
607615 # to_rgba_array("none") returns a (0, 4) array.
You can’t perform that action at this time.
0 commit comments