10000 BUG/API : fix color validation by tacaswell · Pull Request #4193 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

BUG/API : fix color validation #4193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 20, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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".
  • Loading branch information
tacaswell committed Mar 14, 2015
commit cff9efd7426f5977cf47af76376934957e971afc
11 changes: 10 additions & 1 deletion lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ def __call__(self, s):
raise ValueError('Could not convert all entries to ints')


def validate_color_or_None(s):
if s is None:
return None
return validate_color(s)


def validate_color(s):
'return a valid color arg'
try:
Expand All @@ -245,6 +251,7 @@ def validate_color(s):
if is_color_like(s):
return s
stmp = '#' + s

if is_color_like(stmp):
return stmp
# If it is still valid, it must be a tuple.
Expand Down Expand Up @@ -595,7 +602,7 @@ def __call__(self, s):
'image.lut': [256, validate_int], # lookup table
'image.origin': ['upper', six.text_type], # lookup table
'image.resample': [False, validate_bool],
# Specify whether vector graphics backends will combine all images on a
# Specify whether vector graphics backends will combine all images on a
# set of axes into a single composite image
'image.composite_image': [True, validate_bool],

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

## tick properties
'xtick.major.size': [4, validate_float], # major xtick size in points
Expand Down
0