Skip to content

Commit f034cde

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 cff9efd commit f034cde

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/matplotlib/legend.py

+10
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ 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"] == 'inherit':
349+
facecolor = rcParams["axes.facecolor"]
350+
else:
351+
facecolor = rcParams["legend.facecolor"]
352+
353+
if rcParams["legend.edgecolor"] == 'inherit':
354+
edgecolor = rcParams["axes.edgecolor"]
355+
else:
356+
edgecolor = rcParams["legend.edgecolor"]
357+
348358
self.legendPatch = FancyBboxPatch(
349359
xy=(0.0, 0.0), width=1., height=1.,
350360
facecolor=rcParams["axes.facecolor"],

lib/matplotlib/rcsetup.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,10 @@ 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

@@ -692,8 +693,8 @@ def __call__(self, s):
692693
# the relative size of legend markers vs. original
693694
'legend.markerscale': [1.0, validate_float],
694695
'legend.shadow': [False, validate_bool],
695-
'legend.facecolor': [None, validate_color_or_None],
696-
'legend.edgecolor': [None, validate_color_or_None],
696+
'legend.facecolor': ['inherit', validate_color_or_inherit],
697+
'legend.edgecolor': ['inherit', validate_color_or_inherit],
697698

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

0 commit comments

Comments
 (0)