Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 84f0460

Browse files
committed
Merge pull request #2358 from mdboom/fix-inline-figures
Broken IPython notebook integration
2 parents 89e53aa + 8b7382d commit 84f0460

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/matplotlib/figure.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,12 @@ def __init__(self,
344344
# use it, for some reason.
345345

346346
def _repr_html_(self):
347-
from matplotlib.backends import backend_webagg
348-
return backend_webagg.ipython_inline_display(self)
347+
# We can't use "isinstance" here, because then we'd end up importing
348+
# webagg unconditiionally.
349+
if (self.canvas is not None and
350+
'WebAgg' in self.canvas.__class__.__name__):
351+
from matplotlib.backends import backend_webagg
352+
return backend_webagg.ipython_inline_display(self)
349353

350354
def show(self, warn=True):
351355
"""

0 commit comments

Comments
 (0)