8000 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
Show file tree
Hide file tree
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
Prev Previous commit
MNT : try to fix optional/inherited rcparams
Attempt to implement 'inherited' rcparams, that is rcparams
that are only used if they are non-default.

Re-introduces feature introduced in #3792
/92e608d655f1fa667fdf5bc3e99f950eb08f7c42 and reverted in
c90469b
  • Loading branch information
tacaswell committed Mar 14, 2015
commit f034cdee8277787961b596c7837395d8970edca0
10 changes: 10 additions & 0 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,16 @@ def __init__(self, parent, handles, labels,
# We use FancyBboxPatch to draw a legend frame. The location
# and size of the box will be updated during the drawing time.

if rcParams["legend.facecolor"] == 'inherit':
facecolor = rcParams["axes.facecolor"]
else:
facecolor = rcParams["legend.facecolor"]

if rcParams["legend.edgecolor"] == 'inherit':
edgecolor = rcParams["axes.edgecolor"]
else:
edgecolor = rcParams["legend.edgecolor"]

self.legendPatch = FancyBboxPatch(
xy=(0.0, 0.0), width=1., height=1.,
facecolor=rcParams["axes.facecolor"],
Expand Down
11 changes: 6 additions & 5 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,10 @@ 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
def validate_color_or_inherit(s):
'return a valid color arg'
if s == 'inherit':
return s
return validate_color(s)


Expand Down Expand Up @@ -692,8 +693,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],
'legend.facecolor': ['inherit', validate_color_or_inherit],
'legend.edgecolor': ['inherit', validate_color_or_inherit],

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