From a44f66eb937f1477a0676413460e42afcc3edbfc Mon Sep 17 00:00:00 2001 From: Benjamin Congdon Date: Wed, 18 May 2016 20:16:32 -0700 Subject: [PATCH 1/2] labelcolor param now changes offset text color --- lib/matplotlib/axis.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index bd4ae01d36b..c29702aee10 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -796,6 +796,8 @@ def set_tick_params(self, which='major', reset=False, **kw): if which == 'minor' or which == 'both': for tick in self.minorTicks: tick._apply_params(**self._minor_tick_kw) + if 'labelcolor' in kwtrans: + self.offsetText.set_color(kwtrans['labelcolor']) self.stale = True @staticmethod From fd8ec19f680fd4711752ce6d0112ef51620b1eae Mon Sep 17 00:00:00 2001 From: Benjamin Congdon Date: Thu, 19 May 2016 06:42:43 -0700 Subject: [PATCH 2/2] Add offset label color test & what's new entry --- doc/users/whats_new/offset_label_color.rst | 4 ++++ lib/matplotlib/tests/test_axes.py | 10 ++++++++++ 2 files changed, 14 insertions(+) create mode 100644 doc/users/whats_new/offset_label_color.rst diff --git a/doc/users/whats_new/offset_label_color.rst b/doc/users/whats_new/offset_label_color.rst new file mode 100644 index 00000000000..b9ff7ddbbda --- /dev/null +++ b/doc/users/whats_new/offset_label_color.rst @@ -0,0 +1,4 @@ +Axis offset label now responds to `labelcolor` +---------------------------------------------- + +Axis offset labels are now colored the same as axis tick markers when `labelcolor` is altered. \ No newline at end of file diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 52519ce4907..138fd05f2a3 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4478,6 +4478,16 @@ def test_axisbelow(): @cleanup +def test_offset_label_color(): + # Tests issue 6440 + fig = plt.figure() + ax = fig.add_subplot(1, 1, 1) + ax.plot([1.01e9, 1.02e9, 1.03e9]) + ax.yaxis.set_tick_params(labelcolor='red') + assert ax.yaxis.get_offset_text().get_color() == 'red' + + +@cleanup def test_large_offset(): fig, ax = plt.subplots() ax.plot((1 + np.array([0, 1.e-12])) * 1.e27)