8000 MNT : try to fix optional/inherited rcparams · matplotlib/matplotlib@174499e · GitHub
[go: up one dir, main page]

Skip to content

Commit 174499e

Browse files
committed
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
1 parent ff99a04 commit 174499e

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

lib/matplotlib/legend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,12 @@ def __init__(self, parent, handles, labels,
345345
# We use FancyBboxPatch to draw a legend frame. The location
346346
# and size of the box will be updated during the drawing time.
347347

348-
if rcParams["legend.facecolor"] is None:
348+
if rcParams["legend.facecolor"] == 'inherit':
349349
facecolor = rcParams["axes.facecolor"]
350350
else:
351351
facecolor = rcParams["legend.facecolor"]
352352

353-
if rcParams["legend.edgecolor"] is None:
353+
if rcParams["legend.edgecolor"] == 'inherit':
354354
edgecolor = rcParams["axes.edgecolor"]
355355
else:
356356
edgecolor = rcParams["legend.edgecolor"]

lib/matplotlib/rcsetup.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,14 @@ 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
238+
def validate_color_or_inherit(s):
239+
'return a valid color arg'
240+
if s == 'inherit':
241+
return s
241242
return validate_color(s)
242243

243244

244245
def validate_color(s):
245-
'return a valid color arg'
246-
if s is None:
247-
raise ValueError('%s does not look like a color arg' % (s, ))
248-
249246
if is_color_like(s):
250247
return s
251248

@@ -698,8 +695,8 @@ def __call__(self, s):
698695
# the relative size of legend markers vs. original
699696
'legend.markerscale': [1.0, validate_float],
700697
'legend.shadow': [False, validate_bool],
701-
'legend.facecolor': [None, validate_color_or_None],
702-
'legend.edgecolor': [None, validate_color_or_None],
698+
'legend.facecolor': ['inherit', validate_color_or_inherit],
699+
'legend.edgecolor': ['inherit', validate_color_or_inherit],
703700

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

0 commit comments

Comments
 (0)
0