Skip to content

Commit 636003a

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 7a034d2 commit 636003a

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

lib/matplotlib/legend.py

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

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

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

lib/matplotlib/rcsetup.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,14 @@ def __call__(self, s):
225225
raise ValueError('Could not convert all entries to ints')
226226

227227

228-
def validate_color_or_None(s):
229-
if s is None:
230-
return None
228+
def validate_color_or_inherit(s):
229+
'return a valid color arg'
230+
if s == 'inherit':
231+
return s
231232
return validate_color(s)
232233

233234

234235
def validate_color(s):
235-
'return a valid color arg'
236-
if s is None:
237-
raise ValueError('%s does not look like a color arg' % (s, ))
238-
239236
if is_color_like(s):
240237
return s
241238

@@ -674,8 +671,8 @@ def __call__(self, s):
674671
# the relative size of legend markers vs. original
675672
'legend.markerscale': [1.0, validate_float],
676673
'legend.shadow': [False, validate_bool],
677-
'legend.facecolor': [None, validate_color_or_None],
678-
'legend.edgecolor': [None, validate_color_or_None],
674+
'legend.facecolor': ['inherit', validate_color_or_inherit],
675+
'legend.edgecolor': ['inherit', validate_color_or_inherit],
679676

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

0 commit comments

Comments
 (0)