##// END OF EJS Templates
Ported the IPython Sphinx directive to 0.11....
Ported the IPython Sphinx directive to 0.11. This was originally written by John Hunter for the 0.10 API, now it works with 0.11. We still need to automate its test suite, but at least now it runs and the script itself can be executed as a test that produces screen output and figures in a subdir.

File last commit:

r1338:72652d65
r2439:858c6e09
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')