From a202c2cca7bbb6ecf30279cf809c222cc63a4f32 Mon Sep 17 00:00:00 2001 From: Paul Kirow Date: Mon, 29 Feb 2016 17:30:39 -0500 Subject: [PATCH 1/3] Fixed issue 4346 _apply_params was calling setattr on _size and _color instead of _labelsize and _labelcolor --- lib/matplotlib/axis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 8062ebc66e4..6a9ceae5e12 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -340,7 +340,7 @@ def _apply_params(self, **kw): # -> points. grab the integer from the `Text` object # instead of saving the string representation v = getattr(self.label1, 'get_' + k)() - setattr(self, '_' + k, v) + setattr(self, '_label' + k, v) class XTick(Tick): From 58572ced802e228caf652baa0522cfc5eec52fa2 Mon Sep 17 00:00:00 2001 From: Paul Kirow Date: Tue, 1 Mar 2016 13:50:16 -0500 Subject: [PATCH 2/3] Created test for previous issue test will make two calls two set_tick_params. After the fix the second call should not change any of the ticks color or size values. --- lib/matplotlib/tests/test_axes.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index df0e48e0cef..bb2fa34a294 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4335,6 +4335,25 @@ def test_pandas_indexing_hist(): fig, axes = plt.subplots() axes.hist(ser_2) +@cleanup +def test_axis_set_tick_params_two_calls(): + # Tests fix for issue 4346 + axis_1 = plt.subplot() + axis_1.yaxis.set_tick_params(labelsize=30, labelcolor='red', direction='out') + + # Expected values after setting the ticks + assert axis_1.yaxis.majorTicks[0]._size == 4.0 + assert axis_1.yaxis.majorTicks[0]._color == 'k' + assert axis_1.yaxis.majorTicks[0]._labelsize == 30.0 + assert axis_1.yaxis.majorTicks[0]._labelcolor == 'red' + + # This second call to set_tick_params should not change any parameters + axis_1.yaxis.set_tick_params() + + assert axis_1.yaxis.majorTicks[0]._size == 4.0 + assert axis_1.yaxis.majorTicks[0]._color == 'k' + assert axis_1.yaxis.majorTicks[0]._labelsize == 30.0 + assert axis_1.yaxis.majorTicks[0]._labelcolor == 'red' if __name__ == '__main__': import nose From d103d48a11118b548abb92fa8d738578db1a7d07 Mon Sep 17 00:00:00 2001 From: Paul Kirow Date: Tue, 1 Mar 2016 14:01:27 -0500 Subject: [PATCH 3/3] Removed redundancies in test The second call to set_tick_params would mess the padding up only after the first call was causing size and color to be set incorrectly. Thus the test is changed to ensure the root cause is fixed and not the propagation of it --- lib/matplotlib/tests/test_axes.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index bb2fa34a294..70c5c47f810 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4336,7 +4336,7 @@ def test_pandas_indexing_hist(): axes.hist(ser_2) @cleanup -def test_axis_set_tick_params_two_calls(): +def test_axis_set_tick_params_labelsize_labelcolor(): # Tests fix for issue 4346 axis_1 = plt.subplot() axis_1.yaxis.set_tick_params(labelsize=30, labelcolor='red', direction='out') @@ -4347,14 +4347,6 @@ def test_axis_set_tick_params_two_calls(): assert axis_1.yaxis.majorTicks[0]._labelsize == 30.0 assert axis_1.yaxis.majorTicks[0]._labelcolor == 'red' - # This second call to set_tick_params should not change any parameters - axis_1.yaxis.set_tick_params() - - assert axis_1.yaxis.majorTicks[0]._size == 4.0 - assert axis_1.yaxis.majorTicks[0]._color == 'k' - assert axis_1.yaxis.majorTicks[0]._labelsize == 30.0 - assert axis_1.yaxis.majorTicks[0]._labelcolor == 'red' - if __name__ == '__main__': import nose import sys