Skip to content

Commit 0e55ef1

Browse files
committed
Add conditional before set labelcolor call
1 parent e9ebc66 commit 0e55ef1

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/matplotlib/axis.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,15 +2253,18 @@ def _init(self):
22532253
)
22542254
self.label_position = 'bottom'
22552255

2256+
if mpl.rcParams['xtick.labelcolor'] == 'inherit':
2257+
tick_color = mpl.rcParams['xtick.color']
2258+
else:
2259+
tick_color = mpl.rcParams['xtick.labelcolor']
2260+
22562261
self.offsetText.set(
22572262
x=1, y=0,
22582263
verticalalignment='top', horizontalalignment='right',
22592264
transform=mtransforms.blended_transform_factory(
22602265
self.axes.transAxes, mtransforms.IdentityTransform()),
22612266
fontsize=mpl.rcParams['xtick.labelsize'],
2262-
color=mpl.rcParams['xtick.color'] if
2263-
mpl.rcParams['xtick.labelcolor'] == 'inherit' else
2264-
mpl.rcParams['xtick.labelcolor'],
2267+
color=tick_color
22652268
)
22662269
self.offset_text_position = 'bottom'
22672270

@@ -2514,16 +2517,20 @@ def _init(self):
25142517
mtransforms.IdentityTransform(), self.axes.transAxes),
25152518
)
25162519
self.label_position = 'left'
2520+
2521+
if mpl.rcParams['ytick.labelcolor'] == 'inherit':
2522+
tick_color = mpl.rcParams['ytick.color']
2523+
else:
2524+
tick_color = mpl.rcParams['ytick.labelcolor']
2525+
25172526
# x in axes coords, y in display coords(!).
25182527
self.offsetText.set(
25192528
x=0, y=0.5,
25202529
verticalalignment='baseline', horizontalalignment='left',
25212530
transform=mtransforms.blended_transform_factory(
25222531
self.axes.transAxes, mtransforms.IdentityTransform()),
25232532
fontsize=mpl.rcParams['ytick.labelsize'],
2524-
color=mpl.rcParams['ytick.color'] if
2525-
mpl.rcParams['ytick.labelcolor'] == 'inherit' else
2526-
mpl.rcParams['ytick.labelcolor'],
2533+
color=tick_color
25272534
)
25282535
self.offset_text_position = 'left'
25292536

0 commit comments

Comments
 (0)