From 1c8c22793e5d5b495a8ea4f2407b8050463242ae Mon Sep 17 00:00:00 2001 From: lichri12 Date: Thu, 26 Feb 2015 13:26:49 -0500 Subject: [PATCH 1/2] Added set_offset_position in default position Moves offset label back to the left ticks are set back to default position, 'left' is hard coded as 'default' is not a valid position for offset label --- lib/matplotlib/axis.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index b18c567f79cb..5961ce897ea2 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -2128,6 +2128,7 @@ def set_ticks_position(self, position): elif position == 'default': self.set_tick_params(which='both', right=True, labelright=False, left=True, labelleft=True) + self.set_offset_position('left') else: raise ValueError("invalid position: %s" % position) From 6f3c4b56765d4095153647a2289b99ff38851990 Mon Sep 17 00:00:00 2001 From: lichri12 Date: Thu, 26 Feb 2015 14:14:06 -0500 Subject: [PATCH 2/2] Added more tests to test offset label Added a test to test left and default --- lib/matplotlib/tests/test_axes.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 9bcbcfaa8b2d..759254280b30 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -3534,6 +3534,24 @@ def test_move_offsetlabel(): ax.plot(data) ax.yaxis.tick_right() assert_equal((1, 0.5), ax.yaxis.offsetText.get_position()) + +@cleanup +def test_move_offsetlabel_default(): + data = np.random.random(10) * 1e-22 + fig, ax = plt.subplots() + ax.plot(data) + ax.yaxis.tick_right() + ax.yaxis.set_ticks_position('default') + assert_equal((0, 0.5), ax.yaxis.offsetText.get_position()) + +@cleanup +def test_move_offsetlabel_left(): + data = np.random.random(10) * 1e-22 + fig, ax = plt.subplots() + ax.plot(data) + ax.yaxis.tick_right() + ax.yaxis.tick_left() + assert_equal((0, 0.5), ax.yaxis.offsetText.get_position()) if __name__ == '__main__': import nose