Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9527ba5

Browse files
authored
Merge pull request #9633 from tacaswell/fix_labelrotation
FIX: make labelrotation work as kwarg to tick_params as documented
2 parents 1ce2369 + cedef77 commit 9527ba5

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/matplotlib/axis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ def _translate_tick_kw(kw, to_init_kw=True):
828828
'tick1On', 'tick2On', 'label1On', 'label2On']
829829
kwkeys1 = ['length', 'direction', 'left', 'bottom', 'right', 'top',
830830
'labelleft', 'labelbottom', 'labelright', 'labeltop',
831-
'rotation']
831+
'labelrotation']
832832
kwkeys = kwkeys0 + kwkeys1
833833
kwtrans = dict()
834834
if to_init_kw:

lib/matplotlib/tests/test_axes.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5201,15 +5201,23 @@ def test_bar_color_cycle():
52015201

52025202

52035203
def test_tick_param_label_rotation():
5204-
fix, ax = plt.subplots()
5205-
plt.plot([0, 1], [0, 1])
5204+
fix, (ax, ax2) = plt.subplots(1, 2)
5205+
ax.plot([0, 1], [0, 1])
5206+
ax2.plot([0, 1], [0, 1])
52065207
ax.xaxis.set_tick_params(which='both', rotation=75)
52075208
ax.yaxis.set_tick_params(which='both', rotation=90)
52085209
for text in ax.get_xticklabels(which='both'):
52095210
assert text.get_rotation() == 75
52105211
for text in ax.get_yticklabels(which='both'):
52115212
assert text.get_rotation() == 90
52125213

5214+
ax2.tick_params(axis='x', labelrotation=53)
5215+
ax2.tick_params(axis='y', rotation=35)
5216+
for text in ax2.get_xticklabels(which='major'):
5217+
assert text.get_rotation() == 53
5218+
for text in ax2.get_yticklabels(which='major'):
5219+
assert text.get_rotation() == 35
5220+
52135221

52145222
@pytest.mark.style('default')
52155223
def test_fillbetween_cycle():

0 commit comments

Comments
 (0)