##// END OF EJS Templates
general parallel code cleanup
general parallel code cleanup

File last commit:

r1338:72652d65
r3556:b8dd49c8
Show More
parallel_pylab.ipy
46 lines | 1.1 KiB | text/plain | TextLexer
"""Example of how to use pylab to plot parallel data.
The idea here is to run matplotlib is the same IPython session
as an ipython RemoteController client. That way matplotlib
can be used to plot parallel data that is gathered using
RemoteController.
To run this example, first start the IPython controller and 4
engines::
ipcluster -n 4
Then start ipython in pylab mode::
ipython -pylab
Then a simple "run parallel_pylab.ipy" in IPython will run the
example.
"""
import numpy as N
from pylab import *
from IPython.kernel import client
# Get an IPython1 client
rc = client.MultiEngineClient()
rc.get_ids()
rc.activate()
# Create random arrays on the engines
# This is to simulate arrays that you have calculated in parallel
# on the engines.
# Anymore that length 10000 arrays, matplotlib starts to be slow
%px import numpy as N
%px x = N.random.standard_normal(10000)
%px y = N.random.standard_normal(10000)
%px print x[0:10]
%px print y[0:10]
# Bring back the data
x_local = rc.gather('x')
y_local = rc.gather('y')
# Make a scatter plot of the gathered data
plot(x_local, y_local,'ro')