I want to display matplotlib figures in another python process.
My idea is to use a python module that acts as a proxy between the calling python process and the remote python process (I say remote but I am mostly interested in another process on the local machine). So basically doing RPC. For example I would do:
from mplproxy import pyplot as plt
plt.plot(range(10)) # this will call matplotlib.pyplot.plot in the remote process
plt.show() # same here
I figured that IPython Notebook has just that kind of behavior so there might be something there that I can use. Actually I found this SO post which lead me to think I could do this using the IPython package:
Connecting to a remote IPython instance
Using this information I managed to connect to a remote IPython kernel and execute simple shell commands, but I wonder how should the data (method arguments) be transfered? For example: if I wrap a function like
def my_function(*args, **kwargs):
transmit(args)
transmit(kwargs)
shell_channel.execute('my_function(args,kwargs)')
how should args
and kwargs
be transmitted over before I can call the function remotely?
Or maybe there is an easier way to accomplish this?