From cedef77d35db5d8dbc86c8592d32c791c804c37b Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 30 Oct 2017 16:37:06 -0400 Subject: [PATCH] FIX: make labelrotation work as kwarg to tick_params as documented closes #8122 --- lib/matplotlib/axis.py | 2 +- lib/matplotlib/tests/test_axes.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 6cc38bb9066e..55322ce2666e 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -828,7 +828,7 @@ def _translate_tick_kw(kw, to_init_kw=True): 'tick1On', 'tick2On', 'label1On', 'label2On'] kwkeys1 = ['length', 'direction', 'left', 'bottom', 'right', 'top', 'labelleft', 'labelbottom', 'labelright', 'labeltop', - 'rotation'] + 'labelrotation'] kwkeys = kwkeys0 + kwkeys1 kwtrans = dict() if to_init_kw: diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 937de249b536..94833d480f69 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -5201,8 +5201,9 @@ def test_bar_color_cycle(): def test_tick_param_label_rotation(): - fix, ax = plt.subplots() - plt.plot([0, 1], [0, 1]) + fix, (ax, ax2) = plt.subplots(1, 2) + ax.plot([0, 1], [0, 1]) + ax2.plot([0, 1], [0, 1]) ax.xaxis.set_tick_params(which='both', rotation=75) ax.yaxis.set_tick_params(which='both', rotation=90) for text in ax.get_xticklabels(which='both'): @@ -5210,6 +5211,13 @@ def test_tick_param_label_rotation(): for text in ax.get_yticklabels(which='both'): assert text.get_rotation() == 90 + ax2.tick_params(axis='x', labelrotation=53) + ax2.tick_params(axis='y', rotation=35) + for text in ax2.get_xticklabels(which='major'): + assert text.get_rotation() == 53 + for text in ax2.get_yticklabels(which='major'): + assert text.get_rotation() == 35 + @pytest.mark.style('default') def test_fillbetween_cycle():