How to display matplotlib plots on local machine?

I am running ipython remotely on a remote server. I am accessing it with serveraddress: 8888 / etc to write code for my laptops.

When I use matplotlib, of course the plots are inline. Is there a way to send data remotely to get the chart window to open? I want the whole interactive environment on matplotlib on my local machine and all the crunches on the server machine? This is something very basic ... but for some reason after romancing through google for quite some time I can't figure it out.

+3


source to share


3 answers


There are several possibilities

  • If your remote computer is somehow unixish, you can use X Windows (then your session is on the remote computer and shows up on the local computer)

  • mpld3

  • bokeh

    and iPython notebook

  • nbagg

    backend matplotlib

Alternative # 1 requires you to have an X server on your machine and a connection between the two machines (maybe tunneling through ssh, etc.). So it depends on the OS and the performance depends on the connection between the two machines.



Alternatives # 2 and # 3 are new, but promising. They have completely different approaches, mpl3d

allows standard build commands matplotlib

, but bokeh

can be more useful with large datasets .

Alternative # 4 is probably the final solution (see tcaswell

comments), but not yet available without using the development version matplotlib

(i.e. there may be some installation issues). On the other hand, if you can hold your breath for a week, then 1.4.0 is missing.

+3


source


The upcoming release (1.4.0, due before the end of August 2014, release candidates available) will come with a backend nbagg

that provides interactive data from which to go to native clients or resort to using d3.All you need do in your notebook:

import matplotlib
matplotlib.use('nbagg')
from matplotlib import pyplot as plt

      

And then sketch

plt.plot(range(3))
plt.show()

      



If you want to try this now either build from source or look at one of the release candidates.

There are two main differences between usage nbagg

and mpld3 / bokeh.

First, you don't have an interface through the library interfaces (or find out js!). I understand that both of them create a shape, break it (which is not ideal, because mpl was not designed with this simple in mind). With nbagg the mouse and keyboard callbacks should work without translation, I don't think they can be exported to d3.

Secondly, with nbagg, all rendering happens on the server, and d3 based libraries all data should be sent naively to the browser (bokeh is working to make this smarter and only send you the data you can see at a usable resolution). With the nbagg

only thing that gets on the net is the png delta.

+6


source


You want a regular (scalable) chart window, right? I think you cannot do this in the same kernel, since unfortunately you cannot switch from inline to qt, etc., because the backend is already selected: your calls are matplotlib.use()

always before pylab

.

0


source







All Articles