Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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