SorcererofDM
SorcererofDM

Reputation: 331

Make ipython notebook %matplotlib qt pop out plot on client machine

I'm accessing a remote ipython notebook server. I know I can do %matplotlib inline to get inline plots and %matplotlib qt to get popout plots. However, %matplotlib qt pops the plot on the server machine, not the client machine. Is there a way to get the plot to come out on the client machine? The use case is for manipulation of 3d plots (rotation, etc), and I would also appreciate if an alternative way of displaying interactive 3d plots on remote machines is offered.

Upvotes: 4

Views: 1611

Answers (2)

sergei
sergei

Reputation: 3

Update: At the beginning of this SO question a setup you need is described.

Nonoptimal solution: For the exact answer you should determine the way you are connected to the remote mashine (server). I guess you currently have only some command-line access. The solution I came to myself requires the browser installed on the remote mashine and an access to it every time you run the matplotlib script.

(The best way to get interation with matplotlib is to launch a web-server on you remote machine. Then one of the backends of matplotlib should work with the client mashine`s browser. I haven't done this myself yet, because i found another fix - not a solid-working solution. The fix is described below.)

I suggest you to use mpld3 library to do

mpld3.show()

instead of regular

plt.show()

Then the plot will open in you brouser window (localhost) and will be interactive. (Note: not all matplotlib features are currently supported by mpld3. Ex: 'annotate()' is not - use 'text()' instead. SO question)

Then i found a commercial tool - forwardhq.com Their plugin-service combination can create a tunnel to share your localhost webpage. After instalation of their plugin, run your modified script, click on the extiction button (Chrome) and you get a link to share with anyone. (The service has 7 days trial now.)

Upvotes: 0

Mike Müller
Mike Müller

Reputation: 85482

Starting with matplolib 1.4, you can use:

%matplotlib notebook

This creates an in-notebook zoom-able view:

enter image description here

and rotated:

enter image description here

Upvotes: 2

Related Questions