54
54
"""
55
55
from __future__ import (absolute_import , division , print_function ,
56
56
unicode_literals )
57
-
57
+ import re
58
58
from matplotlib .externals import six
59
59
from matplotlib .externals .six .moves import zip
60
60
import warnings
61
- import re
61
+
62
62
import numpy as np
63
63
from numpy import ma
64
64
import matplotlib .cbook as cbook
@@ -194,14 +194,17 @@ def to_rgb(self, arg):
194
194
raise ValueError (
195
195
'to_rgb: arg "%s" is unhashable even inside a tuple'
196
196
% (str (arg ),))
197
-
198
197
try :
199
198
if cbook .is_string_like (arg ):
200
199
argl = arg .lower ()
201
200
color = self .colors .get (argl , None )
202
201
if color is None :
203
202
try :
204
203
argl = self ._parse_nth_color (arg )
204
+ # in this case we do not want to cache in case
205
+ # the rcparam changes, recurse with the actual color
206
+ # value
207
+ return self .to_rgb (argl )
205
208
except ValueError :
206
209
pass
207
210
for cmapping in self .CN_LOOKUPS :
@@ -215,7 +218,7 @@ def to_rgb(self, arg):
215
218
if fl < 0 or fl > 1 :
216
219
raise ValueError (
217
220
'gray (string) must be in range 0-1' )
218
- color = (fl ,)* 3
221
+ color = (fl ,) * 3
219
222
elif cbook .iterable (arg ):
220
223
if len (arg ) > 4 or len (arg ) < 3 :
221
224
raise ValueError (
@@ -228,7 +231,6 @@ def to_rgb(self, arg):
228
231
else :
229
232
raise ValueError (
230
233
'cannot convert argument to rgb sequence' )
231
-
232
234
self .cache [arg ] = color
233
235
234
236
except (KeyError , ValueError , TypeError ) as exc :
0 commit comments