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

Skip to content

Commit 0847006

Browse files
committed
Remove explicit children invalidation in update_position method
This invalidation actually does nothing as the `Line2D` does not have nor use the `_invalid` field. There are `_invalidx` and `_invalidy` fields for this purpose, but them are private members. Moreover, the `set_xdata` and `set_ydata` methods internally invalidate the state (what is more reasonable then an external invalidation).
1 parent 9bfad84 commit 0847006

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
@@ -448,28 +448,16 @@ def _get_gridline(self):
448448

449449
def update_position(self, loc):
450450
'Set the location of tick in data coords with scalar *loc*'
451-
x = loc
452-
453-
nonlinear = (hasattr(self.axes, 'yaxis') and
454-
self.axes.yaxis.get_scale() != 'linear' or
455-
hasattr(self.axes, 'xaxis') and
456-
self.axes.xaxis.get_scale() != 'linear')
457-
458451
if self.tick1On:
459-
self.tick1line.set_xdata((x,))
452+
self.tick1line.set_xdata((loc,))
460453
if self.tick2On:
461-
self.tick2line.set_xdata((x,))
454+
self.tick2line.set_xdata((loc,))
462455
if self.gridOn:
463-
self.gridline.set_xdata((x,))
456+
self.gridline.set_xdata((loc,))
464457
if self.label1On:
465-
self.label1.set_x(x)
458+
self.label1.set_x(loc)
466459
if self.label2On:
467-
self.label2.set_x(x)
468-
469-
if nonlinear:
470-
self.tick1line._invalid = True
471-
self.tick2line._invalid = True
472-
self.gridline._invalid = True
460+
self.label2.set_x(loc)
473461

474462
self._loc = loc
475463
self.stale = True
@@ -582,28 +570,17 @@ def _get_gridline(self):
582570
return l
583571

584572
def update_position(self, loc):
585-
'Set the location of tick in data coords with scalar loc'
586-
y = loc
587-
588-
nonlinear = (hasattr(self.axes, 'yaxis') and
589-
self.axes.yaxis.get_scale() != 'linear' or
590-
hasattr(self.axes, 'xaxis') and
591-
self.axes.xaxis.get_scale() != 'linear')
592-
573+
'Set the location of tick in data coords with scalar *loc*'
593574
if self.tick1On:
594-
self.tick1line.set_ydata((y,))
575+
self.tick1line.set_ydata((loc,))
595576
if self.tick2On:
596-
self.tick2line.set_ydata((y,))
577+
self.tick2line.set_ydata((loc,))
597578
if self.gridOn:
598-
self.gridline.set_ydata((y, ))
579+
self.gridline.set_ydata((loc,))
599580
if self.label1On:
600-
self.label1.set_y(y)
581+
self.label1.set_y(loc)
601582
if self.label2On:
602-
self.label2.set_y(y)
603-
if nonlinear:
604-
self.tick1line._invalid = True
605-
self.tick2line._invalid = True
606-
self.gridline._invalid = True
583+
self.label2.set_y(loc)
607584

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

0 commit comments

Comments
 (0)