Skip to content

Commit e4186b7

Browse files
committed
Support auto for rcParams['axes.labelcolor']
1 parent 955432c commit e4186b7

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

lib/matplotlib/axis.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,11 +658,16 @@ def __init__(self, axes, *, pickradius=15, clear=True):
658658

659659
self._autolabelpos = True
660660

661+
if not cbook._str_lower_equal(mpl.rcParams['axes.labelcolor'], 'auto'):
662+
color = mpl.rcParams['axes.labelcolor']
663+
else:
664+
color = mpl.rcParams['text.color']
665+
661666
self.label = mtext.Text(
662667
np.nan, np.nan,
663668
fontsize=mpl.rcParams['axes.labelsize'],
664669
fontweight=mpl.rcParams['axes.labelweight'],
665-
color=mpl.rcParams['axes.labelcolor'],
670+
color=color
666671
)
667672
self._set_artist_props(self.label)
668673
self.offsetText = mtext.Text(np.nan, np.nan)
@@ -882,7 +887,10 @@ def clear(self):
882887
self.label._reset_visual_defaults()
883888
# The above resets the label formatting using text rcParams,
884889
# so we then update the formatting using axes rcParams
885-
self.label.set_color(mpl.rcParams['axes.labelcolor'])
890+
if not cbook._str_lower_equal(mpl.rcParams['axes.labelcolor'], 'auto'):
891+
self.label.set_color(mpl.rcParams['axes.labelcolor'])
892+
else:
893+
self.label.set_color(mpl.rcParams['text.color'])
886894
self.label.set_fontsize(mpl.rcParams['axes.labelsize'])
887895
self.label.set_fontweight(mpl.rcParams['axes.labelweight'])
888896
self.offsetText._reset_visual_defaults()

lib/matplotlib/mpl-data/matplotlibrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@
378378
#axes.labelsize: medium # font size of the x and y labels
379379
#axes.labelpad: 4.0 # space between label and axis
380380
#axes.labelweight: normal # weight of the x and y labels
381-
#axes.labelcolor: black
381+
#axes.labelcolor: auto
382382
#axes.axisbelow: line # draw axis gridlines and ticks:
383383
# - below patches (True)
384384
# - above patches but below lines ('line')

lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ def _convert_validator_spec(key, conv):
11011101
"axes.labelsize": validate_fontsize, # fontsize of x & y labels
11021102
"axes.labelpad": validate_float, # space between label and axis
11031103
"axes.labelweight": validate_fontweight, # fontsize of x & y labels
1104-
"axes.labelcolor": validate_color, # color of axis label
1104+
"axes.labelcolor": validate_color_or_auto, # color of axis label
11051105
# use scientific notation if log10 of the axis range is smaller than the
11061106
# first or larger than the second
11071107
"axes.formatter.limits": _listify_validator(validate_int, n=2),

0 commit comments

Comments
 (0)