8000 Merge pull request #6445 from benjamincongdon/fix-label-color · matplotlib/matplotlib@9e228e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9e228e6

Browse files
committed
Merge pull request #6445 from benjamincongdon/fix-label-color
Offset text colored by labelcolor param
2 parents 7d66623 + fd8ec19 commit 9e228e6

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Axis offset label now responds to `labelcolor`
2+
----------------------------------------------
3+
4+
Axis offset labels are now colored the same as axis tick markers when `labelcolor` is altered.

lib/matplotlib/axis.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,8 @@ def set_tick_params(self, which='major', reset=False, **kw):
796796
if which == 'minor' or which == 'both':
797797
for tick in self.minorTicks:
798798
tick._apply_params(**self._minor_tick_kw)
799+
if 'labelcolor' in kwtrans:
800+
self.offsetText.set_color(kwtrans['labelcolor'])
799801
self.stale = True
800802

801803
@staticmethod

lib/matplotlib/tests/test_axes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4477,6 +4477,16 @@ def test_axisbelow():
44774477
ax.set_axisbelow(setting)
44784478

44794479

4480+
@cleanup
4481+
def test_offset_label_color():
4482+
# Tests issue 6440
4483+
fig = plt.figure()
4484+
ax = fig.add_subplot(1, 1, 1)
4485+
ax.plot([1.01e9, 1.02e9, 1.03e9])
4486+
ax.yaxis.set_tick_params(labelcolor='red')
4487+
assert ax.yaxis.get_offset_text().get_color() == 'red'
4488+
4489+
44804490
@cleanup
44814491
def test_large_offset():
44824492
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)
0