8000 BUG/API : fix color validation · matplotlib/matplotlib@cff9efd · GitHub
[go: up one dir, main page]

Skip to content

Commit cff9efd

Browse files
committed
BUG/API : fix color validation
Possible fix for #4192. This adds a new validation (validate_color_or_None) method for color which allows None and restores `validate_color` to fail on None. This will allow selected color rcparams to be `None` (not `'None'`) which the library should interpret as "don't use this rcparam".
1 parent c90469b commit cff9efd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/matplotlib/rcsetup.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ def __call__(self, s):
235235
raise ValueError('Could not convert all entries to ints')
236236

237237

238+
def validate_color_or_None(s):
239+
if s is None:
240+
return None
241+
return validate_color(s)
242+
243+
238244
def validate_color(s):
239245
'return a valid color arg'
240246
try:
@@ -245,6 +251,7 @@ def validate_color(s):
245251
if is_color_like(s):
246252
return s
247253
stmp = '#' + s
254+
248255
if is_color_like(stmp):
249256
return stmp
250257
# If it is still valid, it must be a tuple.
@@ -595,7 +602,7 @@ def __call__(self, s):
595602
'image.lut': [256, validate_int], # lookup table
596603
'image.origin': ['upper', six.text_type], # lookup table
597604
'image.resample': [False, validate_bool],
598-
# Specify whether vector graphics backends will combine all images on a
605+
# Specify whether vector graphics backends will combine all images on a
599606
# set of axes into a single composite image
600607
'image.composite_image': [True, validate_bool],
601608

@@ -685,6 +692,8 @@ def __call__(self, s):
685692
# the relative size of legend markers vs. original
686693
'legend.markerscale': [1.0, validate_float],
687694
'legend.shadow': [False, validate_bool],
695+
'legend.facecolor': [None, validate_color_or_None],
696+
'legend.edgecolor': [None, validate_color_or_None],
688697

689698
## tick properties
690699
'xtick.major.size': [4, validate_float], # major xtick size in points

0 commit comments

Comments
 (0)
0