def add(self, key, a): """ Add Axes *a*, with key *key*, to the stack, and return the stack. If *a* is already on the stack, don't add it again, but return *None*. """ # All the error checking may be unnecessary; but this method # is called so seldom that the overhead is negligible. if not isinstance(a, Axes): raise ValueError("second argument, %s, is not an Axes" % a) try: hash(key) except TypeError: raise ValueError("first argument, %s, is not a valid key" % key) a_existing = self.get(key) if a_existing is not None: Stack.remove(self, (key, a_existing)) import warnings warnings.warn( "key %s already existed; Axes is being replaced" % key) # I don't think the above should ever happen. if a in self: return None self._ind += 1 return Stack.push(self, (key, (self._ind, a)))
def update(self, *data, **opts): self.cplot.set_data(*data) if 'extent' in opts: self.cplot.set_extent(opts['extent']) oldviews=self.toolbar._views if self.toolbar._views: # set the new extent as home for the new data newviews=Stack() newviews.push([tuple(opts['extent'])]) for item in oldviews[1:]: newviews.push(item) self.toolbar._views=newviews if not oldviews or oldviews[oldviews._pos]==oldviews[0]: self.canvas.ax.set_xlim(opts['extent'][0], opts['extent'][1]) self.canvas.ax.set_ylim(opts['extent'][2], opts['extent'][3])
def bubble(self, a): """ Move the given axes, which must already exist in the stack, to the top. """ return Stack.bubble(self, self._entry_from_axes(a))
def remove(self, a): """Remove the axes from the stack.""" Stack.remove(self, self._entry_from_axes(a))
def __init__(self): Stack.__init__(self) self._ind = 0