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

Skip to content

WebAgg: Fix IPython detection. Fix encoding error on Python 3 #2834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 17, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions lib/matplotlib/backends/backend_webagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@
from matplotlib._pylab_helpers import Gcf
from . import backend_webagg_core as core

# TODO: This should really only be set for the IPython notebook, but
# I'm not sure how to detect that.
try:
__IPYTHON__
except:
_in_ipython = False
else:
_in_ipython = True


def new_figure_manager(num, *args, **kwargs):
"""
Expand Down Expand Up @@ -95,17 +86,7 @@ def mainloop(self):
WebAggApplication.start()


if not _in_ipython:
show = Show()
else:
def show():
from IPython.display import display_html

result = []
import matplotlib._pylab_helpers as pylab_helpers
for manager in pylab_helpers.Gcf().get_all_fig_managers():
result.append(ipython_inline_display(manager.canvas.figure))
return display_html('\n'.join(result), raw=True)
show = Show().mainloop


class ServerThread(threading.Thread):
Expand Down Expand Up @@ -398,7 +379,7 @@ def ipython_inline_display(figure):
fig_id=fignum,
toolitems=core.NavigationToolbar2WebAgg.toolitems,
canvas=figure.canvas,
port=WebAggApplication.port)
port=WebAggApplication.port).decode('utf-8')


FigureCanvas = FigureCanvasWebAgg