How to use the ipympl.backend_nbagg.FigureManager function in ipympl

To help you get started, we’ve selected a few ipympl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holoviz / panel / panel / pane / plot.py View on Github external
def _get_widget(self, fig):
        import matplotlib
        old_backend = getattr(matplotlib.backends, 'backend', 'agg')

        from ipympl.backend_nbagg import FigureManager, Canvas, is_interactive
        from matplotlib._pylab_helpers import Gcf

        matplotlib.use(old_backend)

        def closer(event):
            Gcf.destroy(0)

        canvas = Canvas(fig)
        fig.patch.set_alpha(0)
        manager = FigureManager(canvas, 0)

        if is_interactive():
            fig.canvas.draw_idle()

        canvas.mpl_connect('close_event', closer)
        return manager
github matplotlib / jupyter-matplotlib / ipympl / backend_nbagg.py View on Github external
def new_figure_manager_given_figure(num, figure):
    """
    Create a new figure manager instance for the given figure.
    """
    from matplotlib._pylab_helpers import Gcf

    def closer(event):
        Gcf.destroy(num)

    canvas = Canvas(figure)
    if 'nbagg.transparent' in set(rcParams.keys()) and rcParams['nbagg.transparent']:
        figure.patch.set_alpha(0)
    manager = FigureManager(canvas, num)

    if is_interactive():
        manager.show()
        figure.canvas.draw_idle()

    canvas.mpl_connect('close_event', closer)

    return manager
github glue-viz / glue-jupyter / glue_jupyter / matplotlib / base.py View on Github external
def __init__(self, session, parent=None, wcs=None, state=None):

        self.figure = Figure()
        self.canvas = Canvas(self.figure)
        self.canvas.manager = FigureManager(self.canvas, 0)
        self.figure, self.axes = init_mpl(self.figure, wcs=wcs)

        # FIXME: The following is required for now for the tools to work
        self.central_widget = self.figure
        self._axes = self.axes

        super(MatplotlibJupyterViewer, self).__init__(session, state=state)

        MatplotlibViewerMixin.setup_callbacks(self)

        self.css_widget = HTML(REMOVE_TITLE_CSS)

        self.create_layout()