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

Skip to content

Commit a578a7a

Browse files
authored
Merge pull request #6692 from Kojoley/cleanup-axis-update_position
MNT: Remove explicit children invalidation in update_position method
2 parents 5443e81 + 0847006 commit a578a7a

File tree

1 file changed

+11
-34
lines changed

1 file changed

+11
-34
lines changed

lib/matplotlib/axis.py

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -449,28 +449,16 @@ def _get_gridline(self):
449449

450450
def update_position(self, loc):
451451
'Set the location of tick in data coords with scalar *loc*'
452-
x = loc
453-
454-
nonlinear = (hasattr(self.axes, 'yaxis') and
455-
self.axes.yaxis.get_scale() != 'linear' or
456-
hasattr(self.axes, 'xaxis') and
457-
self.axes.xaxis.get_scale() != 'linear')
458-
459452
if self.tick1On:
460-
self.tick1line.set_xdata((x,))
453+
self.tick1line.set_xdata((loc,))
461454
if self.tick2On:
462-
self.tick2line.set_xdata((x,))
455+
self.tick2line.set_xdata((loc,))
463456
if self.gridOn:
464-
self.gridline.set_xdata((x,))
457+
self.gridline.set_xdata((loc,))
465458
if self.label1On:
466-
self.label1.set_x(x)
459+
self.label1.set_x(loc)
467460
if self.label2On:
468-
self.label2.set_x(x)
469-
470-
if nonlinear:
471-
self.tick1line._invalid = True
472-
self.tick2line._invalid = True
473-
self.gridline._invalid = True
461+
self.label2.set_x(loc)
474462

475463
self._loc = loc
476464
self.stale = True
@@ -583,28 +571,17 @@ def _get_gridline(self):
583571
return l
584572

585573
def update_position(self, loc):
586-
'Set the location of tick in data coords with scalar loc'
587-
y = loc
588-
589-
nonlinear = (hasattr(self.axes, 'yaxis') and
590-
self.axes.yaxis.get_scale() != 'linear' or
591-
hasattr(self.axes, 'xaxis') and
592-
self.axes.xaxis.get_scale() != 'linear')
593-
574+
'Set the location of tick in data coords with scalar *loc*'
594575
if self.tick1On:
595-
self.tick1line.set_ydata((y,))
576+
self.tick1line.set_ydata((loc,))
596577
if self.tick2On:
597-
self.tick2line.set_ydata((y,))
578+
self.tick2line.set_ydata((loc,))
598579
if self.gridOn:
599-
self.gridline.set_ydata((y, ))
580+
self.gridline.set_ydata((loc,))
600581
if self.label1On:
601-
self.label1.set_y(y)
582+
self.label1.set_y(loc)
602583
if self.label2On:
603-
self.label2.set_y(y)
604-
if nonlinear:
605-
self.tick1line._invalid = True
606-
self.tick2line._invalid = True
607-
self.gridline._invalid = True
584+
self.label2.set_y(loc)
608585

609586
self._loc = loc
610587
self.stale = True

0 commit comments

Comments
 (0)