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

Skip to content

Commit 2c10dcb

Browse files
committed
ENH : add stale flag to Spines
1 parent 79d971d commit 2c10dcb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/matplotlib/spines.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def set_smart_bounds(self, value):
9696
self.axes.yaxis.set_smart_bounds(value)
9797
elif self.spine_type in ('top', 'bottom'):
9898
self.axes.xaxis.set_smart_bounds(value)
99+
self.stale = True
99100

100101
def get_smart_bounds(self):
101102
"""get whether the spine has smart bounds"""
@@ -110,10 +111,12 @@ def set_patch_circle(self, center, radius):
110111
self._angle = 0
111112
# circle drawn on axes transform
112113
self.set_transform(self.axes.transAxes)
114+
self.stale = True
113115

114116
def set_patch_line(self):
115117
"""set the spine to be linear"""
116118
self._patch_type = 'line'
119+
self.stale = True
117120

118121
# Behavior copied from mpatches.Ellipse:
119122
def _recompute_transform(self):
@@ -158,6 +161,7 @@ def register_axis(self, axis):
158161
self.axis = axis
159162
if self.axis is not None:
160163
self.axis.cla()
164+
self.stale = True
161165

162166
def cla(self):
163167
"""Clear the current spine"""
@@ -274,7 +278,9 @@ def _adjust_location(self):
274278
@allow_rasterization
275279
def draw(self, renderer):
276280
self._adjust_location()
277-
return super(Spine, self).draw(renderer)
281+
ret = super(Spine, self).draw(renderer)
282+
self.stale = False
283+
return ret
278284

279285
def _calc_offset_transform(self):
280286
"""calculate the offset transform performed by the spine"""
@@ -388,6 +394,7 @@ def set_position(self, position):
388394

389395
if self.axis is not None:
390396
self.axis.reset_ticks()
397+
self.stale = True
391398

392399
def get_position(self):
393400
"""get the spine position"""
@@ -437,6 +444,7 @@ def set_bounds(self, low, high):
437444
raise ValueError(
438445
'set_bounds() method incompatible with circular spines')
439446
self._bounds = (low, high)
447+
self.stale = True
440448

441449
def get_bounds(self):
442450
"""Get the bounds of the spine."""
@@ -486,3 +494,4 @@ def set_color(self, c):
486494
# The facecolor of a spine is always 'none' by default -- let
487495
# the user change it manually if desired.
488496
self.set_edgecolor(c)
497+
self.stale = True

0 commit comments

Comments
 (0)