In [2]:
%pylab inline
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as anim
x1 = np.load("paths_D=5_M=200_dt=0.1_Lfrac=0.4.npy")
x2 = np.load("paths_D=5_M=100_dt=0.2_Lfrac=0.4.npy")
x3 = np.load("paths_D=5_M=40_dt=0.5_Lfrac=0.4.npy")
y1 = np.load("params_D=5_M=200_dt=0.1_Lfrac=0.4.npy")
y2 = np.load("params_D=5_M=100_dt=0.2_Lfrac=0.4.npy")
y3 = np.load("params_D=5_M=40_dt=0.5_Lfrac=0.4.npy")
z1 = np.load("action_errors_D=5_M=200_dt=0.1_Lfrac=0.4.npy")
z2 = np.load("action_errors_D=5_M=100_dt=0.2_Lfrac=0.4.npy")
z3 = np.load("action_errors_D=5_M=40_dt=0.5_Lfrac=0.4.npy")


Populating the interactive namespace from numpy and matplotlib

In [4]:
data = x1
pylab.rcParams['figure.figsize'] = (18, 18)
for i in range(1,len(data[1,1,:])):
    plt.subplot(len(data[1,1,:]),1,i)
    plt.plot(data[1,:,0],np.transpose(data[:,:,i]));
    #plt.plot(x2[1,:,0],np.transpose(x2[:,:,i]),'.');



In [1]:
data = x1
dump = np.ones(200,5)
pylab.rcParams['figure.figsize'] = (10, 10)
for i in range(1,len(data[1,1,:])):
    data[:,:,i];


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-5cfd2c52e683> in <module>()
----> 1 data = x1
      2 dump = np.ones(200,5)
      3 pylab.rcParams['figure.figsize'] = (10, 10)
      4 for i in range(1,len(data[1,1,:])):
      5     data[:,:,i];

NameError: name 'x1' is not defined

In [10]:
data = y1
pylab.rcParams['figure.figsize'] = (10, 10)
plt.plot(data);



In [19]:
data = z1
pylab.rcParams['figure.figsize'] = (10, 10)
plt.plot(data[:,1:3]);



In [20]:
%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt

from matplotlib import animation, rc
from IPython.display import HTML

# First set up the figure, the axis, and the plot element we want to animate
fig, ax = plt.subplots();

ax.set_ylim(( -15, 15))
ax.set_xlim((0, 10))

line, = ax.plot([], [], lw=2);

# initialization function: plot the background of each frame
def init():
    line.set_data([], [])
    return (line,)

# animation function. This is called sequentially
# def animate(i):
#     x = np.linspace(0, 2, 1000)
#     y = np.sin(2 * np.pi * (x - 0.01 * i))
#     line.set_data(x, y)
#     return (line,)

def animate(i):
    x = x1[0,:,0]
    y = x1[i,:,4]
    line.set_data(x, y)
    return (line,)


# call the animator. blit=True means only re-draw the parts that have changed.
anim = animation.FuncAnimation(fig, animate, init_func=init,
                               frames=100, interval=50, blit=True);



In [32]:
HTML(anim.to_html5_video())


Out[32]: