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

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
BUG: adjust tick label location when tick length changes
Closes #7114.
  • Loading branch information
efiring committed Sep 15, 2016
commit f9d2381ffdee2fbddf0e8d48364df718c0a09e89
25 changes: 11 additions & 14 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,33 +300,30 @@ def _apply_params(self, **kw):
switches = [k for k in kw if k in switchkw]
for k in switches:
setattr(self, k, kw.pop(k))
dirpad = [k for k in kw if k in ['pad', 'tickdir']]
if dirpad:
newmarker = [k for k in kw if k in ['size', 'width', 'pad', 'tickdir']]
if newmarker:
self._size = kw.pop('size', self._size)
self._width = kw.pop('width', self._width)
self._base_pad = kw.pop('pad', self._base_pad)
# apply_tickdir makes _pad and _tickmarkers
self.apply_tickdir(kw.pop('tickdir', self._tickdir))
self.tick1line.set_marker(self._tickmarkers[0])
self.tick2line.set_marker(self._tickmarkers[1])
for line in (self.tick1line, self.tick2line):
line.set_markersize(self._size)
line.set_markeredgewidth(self._width)
# _get_text1_transform uses _pad from apply_tickdir
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should add a comment mentioning that apply_tickdir uses self._size to compute the self._pad value, as this was the core of the problem here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a commit to flesh out the comments.

trans = self._get_text1_transform()[0]
self.label1.set_transform(trans)
trans = self._get_text2_transform()[0]
self.label2.set_transform(trans)
self.tick1line.set_marker(self._tickmarkers[0])
self.tick2line.set_marker(self._tickmarkers[1])
tick_kw = dict([kv for kv in six.iteritems(kw)
if kv[0] in ['color', 'zorder']])
if tick_kw:
self.tick1line.set(**tick_kw)
self.tick2line.set(**tick_kw)
for k, v in six.iteritems(tick_kw):
setattr(self, '_' + k, v)
tick_list = [kv for kv
in six.iteritems(kw) if kv[0] in ['size', 'width']]
for k, v in tick_list:
setattr(self, '_' + k, v)
if k == 'size':
self.tick1line.set_markersize(v)
self.tick2line.set_markersize(v)
else:
self.tick1line.set_markeredgewidth(v)
self.tick2line.set_markeredgewidth(v)
label_list = [k for k in six.iteritems(kw)
if k[0] in ['labelsize', 'labelcolor']]
if label_list:
Expand Down