def __init__(self, figure, *args, **kwargs): DOMWidget.__init__(self, *args, **kwargs) FigureCanvasWebAggCore.__init__(self, figure, *args, **kwargs) self.on_msg(self._handle_message) # This will stay True for cases where there is no # front-end (e.g. nbconvert --execute) self.syncing_data_url = True
def new_figure_manager_given_figure(num, figure): """ Create a new figure manager instance for the given figure. """ canvas = FigureCanvasWebAggCore(figure) manager = FigureManagerNbAgg(canvas, num) return manager
def flush(self, key=None): if key is None: figs = self._figures.values() managers = self._managers.values() else: figs = [self._figures[key]] managers = [self._managers[key]] for figure, manager in zip(figs, managers): canvas = FigureCanvasWebAggCore(figure) manager.canvas = canvas manager.canvas.manager = manager manager._get_toolbar(canvas) manager._send_event("refresh") manager.canvas.draw()
def refresh_figures(self, figures=None): if figures is None: self.figures = create_default_figures() else: self.figures = figures for k, f in self.figures.items(): if k not in self.managers: fignum = id(f) self.managers[k] = new_figure_manager_given_figure(fignum, f) self.fig_id_map[fignum] = self.managers[k] else: canvas = FigureCanvasWebAggCore(f) self.managers[k].canvas = canvas self.managers[k].canvas.manager = self.managers[k] self.managers[k]._get_toolbar(canvas) self.managers[k]._send_event("refresh") self.managers[k].canvas.draw()
def __init__(self, figure, *args, **kwargs): DOMWidget.__init__(self, *args, **kwargs) FigureCanvasWebAggCore.__init__(self, figure, *args, **kwargs) self.on_msg(self._handle_message)