From 8b7382d6d0c1e490057f2ccd4e52face63505f24 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 30 Aug 2013 11:17:48 -0400 Subject: [PATCH] Make pylab inline figures work again --- lib/matplotlib/figure.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index af6fe7babc50..20b918407047 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -344,8 +344,12 @@ def __init__(self, # use it, for some reason. def _repr_html_(self): - from matplotlib.backends import backend_webagg - return backend_webagg.ipython_inline_display(self) + # We can't use "isinstance" here, because then we'd end up importing + # webagg unconditiionally. + if (self.canvas is not None and + 'WebAgg' in self.canvas.__class__.__name__): + from matplotlib.backends import backend_webagg + return backend_webagg.ipython_inline_display(self) def show(self, warn=True): """