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

Skip to content

Commit 76f902c

Browse files
committed
Merge pull request matplotlib#2834 from mdboom/webagg/ipython-detection
WebAgg: Fix IPython detection. Fix encoding error on Python 3
2 parents af7198c + 03fc978 commit 76f902c

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

lib/matplotlib/backends/backend_webagg.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@
4040
from matplotlib._pylab_helpers import Gcf
4141
from . import backend_webagg_core as core
4242

43-
# TODO: This should really only be set for the IPython notebook, but
44-
# I'm not sure how to detect that.
45-
try:
46-
__IPYTHON__
47-
except:
48-
_in_ipython = False
49-
else:
50-
_in_ipython = True
51-
5243

5344
def new_figure_manager(num, *args, **kwargs):
5445
"""
@@ -95,17 +86,7 @@ def mainloop(self):
9586
WebAggApplication.start()
9687

9788

98-
if not _in_ipython:
99-
show = Show()
100-
else:
101-
def show():
102-
from IPython.display import display_html
103-
104-
result = []
105-
import matplotlib._pylab_helpers as pylab_helpers
106-
for manager in pylab_helpers.Gcf().get_all_fig_managers():
107-
result.append(ipython_inline_display(manager.canvas.figure))
108-
return display_html('\n'.join(result), raw=True)
89+
show = Show().mainloop
10990

11091

11192
class ServerThread(threading.Thread):
@@ -408,7 +389,7 @@ def ipython_inline_display(figure):
408389
fig_id=fignum,
409390
toolitems=core.NavigationToolbar2WebAgg.toolitems,
410391
canvas=figure.canvas,
411-
port=WebAggApplication.port)
392+
port=WebAggApplication.port).decode('utf-8')
412393

413394

414395
FigureCanvas = FigureCanvasWebAgg

0 commit comments

Comments
 (0)