8000 set_tick_params now responds to · matplotlib/matplotlib@6dfb8cc · GitHub
[go: up one dir, main page]

Skip to content

Commit 6dfb8cc

Browse files
committed
set_tick_params now responds to
1 parent c04e756 commit 6dfb8cc

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

doc/users/whats_new/tick_params_rotation.rst

Whitespace-only changes.

lib/matplotlib/axis.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def __init__(self, axes, loc, label,
7373
pad=None,
7474
labelsize=None,
7575
labelcolor=None,
76+
labelrotation=0,
7677
zorder=None,
7778
gridOn=None, # defaults to axes.grid depending on
7879
# axes.grid.which
@@ -139,6 +140,8 @@ def __init__(self, axes, loc, label,
139140
labelsize = rcParams['%s.labelsize' % name]
140141
self._labelsize = labelsize
141142

143+
self._labelrotation = labelrotation
144+
142145
if zorder is None:
143146
if major:
144147
zorder = mlines.Line2D.zorder + 0.01
@@ -333,7 +336,7 @@ def _apply_params(self, **kw):
333336
self.tick1line.set_markeredgewidth(v)
334337
self.tick2line.set_markeredgewidth(v)
335338
label_list = [k for k in six.iteritems(kw)
336-
if k[0] in ['labelsize', 'labelcolor']]
339+
if k[0] in ['labelsize', 'labelcolor', 'labelrotation']]
337340
if label_list:
338341
label_kw = dict([(k[5:], v) for (k, v) in label_list])
339342
self.label1.set(**label_kw)
@@ -798,14 +801,17 @@ def _translate_tick_kw(kw, to_init_kw=True):
798801
'labelsize', 'labelcolor', 'zorder', 'gridOn',
799802
'tick1On', 'tick2On', 'label1On', 'label2On']
800803
kwkeys1 = ['length', 'direction', 'left', 'bottom', 'right', 'top',
801-
'labelleft', 'labelbottom', 'labelright', 'labeltop']
804+
'labelleft', 'labelbottom', 'labelright', 'labeltop',
805+
'rotation']
802806
kwkeys = kwkeys0 + kwkeys1
803807
kwtrans = dict()
804808
if to_init_kw:
805809
if 'length' in kw:
806810
kwtrans['size'] = kw.pop('length')
807811
if 'direction' in kw:
808812
kwtrans['tickdir'] = kw.pop('direction')
813+
if 'rotation' in kw:
814+
kwtrans['labelrotation'] = kw.pop('rotation')
809815
if 'left' in kw:
810816
kwtrans['tick1On'] = _string_to_bool(kw.pop('left'))
811817
if 'bottom' in kw:

lib/matplotlib/tests/test_axes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4549,6 +4549,18 @@ def test_bar_color_cycle():
45494549
assert ccov(ln.get_color()) == ccov(br.get_facecolor())
45504550

45514551

4552+
@cleanup
4553+
def test_tick_param_label_rotation():
4554+
fix, ax = plt.subplots()
4555+
plt.plot([0, 1], [0, 1])
4556+
ax.xaxis.set_tick_params(which='both', rotation=75)
4557+
ax.yaxis.set_tick_params(which='both', rotation=90)
4558+
for text in ax.get_xticklabels(which='both'):
4559+
assert text.get_rotation() == 75
4560+
for text in ax.get_yticklabels(which='both'):
4561+
assert text.get_rotation() == 90
4562+
4563+
45524564
if __name__ == '__main__':
45534565
import nose
45544566
import sys

0 commit comments

Comments
 (0)
0