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

Skip to content

Commit 3df2df1

Browse files
committed
Merge pull request #6445 from benjamincongdon/fix-label-color
Offset text colored by labelcolor param
1 parent 58105d7 commit 3df2df1

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
@@ -4475,6 +4475,16 @@ def test_axisbelow():
44754475
ax.set_axisbelow(setting)
44764476

44774477

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

0 commit comments

Comments
 (0)
0