""" Manage figures for pyplot interface. """
""" Singleton to manage a set of integer-numbered figures.
This class is never instantiated; it consists of two class attributes (a list and a dictionary), and a set of static methods that operate on those attributes, accessing them directly as class attributes.
Attributes:
*figs*: dictionary of the form {*num*: *manager*, ...}
*_activeQue*: list of *managers*, with active one at the end
"""
def get_fig_manager(cls, num): """ If figure manager *num* exists, make it the active figure and return the manager; otherwise return *None*. """ cls.set_active(manager)
def destroy(cls, num): """ Try to remove all traces of figure *num*.
In the interactive backends, this is bound to the window "destroy" and "delete" events. """ return
def destroy_fig(cls, fig): "*fig* is a Figure instance" if manager.canvas.figure == fig), None)
def destroy_all(cls): # this is need to ensure that gc is available in corner cases # where modules are being torn down after install with easy_install manager.canvas.mpl_disconnect(manager._cidgcf) manager.destroy()
def has_fignum(cls, num): """ Return *True* if figure *num* exists. """
def get_all_fig_managers(cls): """ Return a list of figure managers. """ return list(cls.figs.values())
def get_num_fig_managers(cls): """ Return the number of figures being managed. """ return len(cls.figs)
def get_active(cls): """ Return the manager of the active figure, or *None*. """ if len(cls._activeQue) == 0: return None else: return cls._activeQue[-1]
def set_active(cls, manager): """ Make the figure corresponding to *manager* the active one. """
""" Redraw all figures registered with the pyplot state machine. """ for f_mgr in cls.get_all_fig_managers(): if force or f_mgr.canvas.figure.stale: f_mgr.canvas.draw_idle()
|