Skip to content

Commit bc22725

Browse files
committed
Default x/ytick.labelcolor to text.color
1 parent e4186b7 commit bc22725

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

lib/matplotlib/axis.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def __init__(
129129
if labelcolor is None:
130130
labelcolor = mpl.rcParams[f"{name}.labelcolor"]
131131

132-
if cbook._str_equal(labelcolor, 'inherit'):
133-
# inherit from tick color
134-
labelcolor = mpl.rcParams[f"{name}.color"]
132+
if (cbook._str_equal(labelcolor, 'inherit') or
133+
cbook._str_equal(labelcolor, 'auto')):
134+
labelcolor = mpl.rcParams["text.color"]
135135

136136
if labelsize is None:
137137
labelsize = mpl.rcParams[f"{name}.labelsize"]
@@ -2591,10 +2591,11 @@ def _init(self):
25912591
)
25922592
self.label_position = 'left'
25932593

2594-
if mpl.rcParams['ytick.labelcolor'] == 'inherit':
2595-
tick_color = mpl.rcParams['ytick.color']
2596-
else:
2597-
tick_color = mpl.rcParams['ytick.labelcolor']
2594+
tick_color = mpl.rcParams['ytick.labelcolor']
2595+
2596+
if (cbook._str_equal(tick_color, 'inherit') or
2597+
cbook._str_equal(tick_color, 'auto')):
2598+
tick_color = mpl.rcParams["text.color"]
25982599

25992600
# x in axes coords, y in display coords(!).
26002601
self.offsetText.set(

lib/matplotlib/mpl-data/matplotlibrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@
482482
#xtick.major.pad: 3.5 # distance to major tick label in points
483483
#xtick.minor.pad: 3.4 # distance to the minor tick label in points
484484
#xtick.color: black # color of the ticks
485-
#xtick.labelcolor: inherit # color of the tick labels or inherit from xtick.color
485+
#xtick.labelcolor: auto # color of the tick labels or default to text.color
486486
#xtick.labelsize: medium # font size of the tick labels
487487
#xtick.direction: out # direction: {in, out, inout}
488488
#xtick.minor.visible: False # visibility of minor ticks on x-axis
@@ -504,7 +504,7 @@
504504
#ytick.major.pad: 3.5 # distance to major tick label in points
505505
#ytick.minor.pad: 3.4 # distance to the minor tick label in points
506506
#ytick.color: black # color of the ticks
507-
#ytick.labelcolor: inherit # color of the tick labels or inherit from ytick.color
507+
#ytick.labelcolor: auto # color of the tick labels or default to text.color
508508
#ytick.labelsize: medium # font size of the tick labels
509509
#ytick.direction: out # direction: {in, out, inout}
510510
#ytick.minor.visible: False # visibility of minor ticks on y-axis

lib/matplotlib/rcsetup.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ def validate_color_or_auto(s):
301301
return validate_color(s)
302302

303303

304+
def validate_color_inherit_or_auto(s):
305+
if cbook._str_equal(s, 'inherit') or cbook._str_equal(s, 'auto'):
306+
return s
307+
return validate_color(s)
308+
309+
304310
def validate_color_for_prop_cycle(s):
305311
# N-th color cycle syntax can't go into the color cycle.
306312
if isinstance(s, str) and re.match("^C[0-9]$", s):
@@ -1199,7 +1205,7 @@ def _convert_validator_spec(key, conv):
11991205
"xtick.major.pad": validate_float, # distance to label in points
12001206
"xtick.minor.pad": validate_float, # distance to label in points
12011207
"xtick.color": validate_color, # color of xticks
1202-
"xtick.labelcolor": validate_color_or_inherit, # color of xtick labels
1208+
"xtick.labelcolor": validate_color_inherit_or_auto, # color of xtick labels
12031209
"xtick.minor.visible": validate_bool, # visibility of minor xticks
12041210
"xtick.minor.top": validate_bool, # draw top minor xticks
12051211
"xtick.minor.bottom": validate_bool, # draw bottom minor xticks
@@ -1222,7 +1228,7 @@ def _convert_validator_spec(key, conv):
12221228
"ytick.major.pad": validate_float, # distance to label in points
12231229
"ytick.minor.pad": validate_float, # distance to label in points
12241230
"ytick.color": validate_color, # color of yticks
1225-
"ytick.labelcolor": validate_color_or_inherit, # color of ytick labels
1231+
"ytick.labelcolor": validate_color_inherit_or_auto, # color of ytick labels
12261232
"ytick.minor.visible": validate_bool, # visibility of minor yticks
12271233
"ytick.minor.left": validate_bool, # draw left minor yticks
12281234
"ytick.minor.right": validate_bool, # draw right minor yticks

0 commit comments

Comments
 (0)