2 import matplotlib.pyplot
as plt
3 import matplotlib.lines
as ln
4 import matplotlib.animation
as animation
9 def update_line(num, data, line):
11 line.set_data(data[...,:num])
16 data = np.random.rand(2, 25)
18 l, = plt.plot([], [],
'r-')
23 line_ani = animation.FuncAnimation(fig1, update_line, 25, fargs=(data, l),
24 interval=1000, blit=
True)
32 y = np.arange(-9, 10).reshape(-1, 1)
35 for add
in np.arange(15):
36 ims.append((plt.pcolor(x, y, base + add, norm=plt.Normalize(0, 30)),))
38 im_ani = animation.ArtistAnimation(fig2, ims, interval=50, repeat_delay=3000,
44 def __init__(self, ax, maxt=2, dt=0.02):
51 self.ax.add_line(self.
line)
52 self.ax.set_ylim(-.1, 1.1)
53 self.ax.set_xlim(0, self.
maxt)
56 lastt = self.
tdata[-1]
61 self.ax.figure.canvas.draw()
70 'return a random value with probability p, else 0' 76 yield np.random.rand(1)
78 fig, ax = plt.subplots()
82 ani = animation.FuncAnimation(fig, scope.update, emitter, interval=10,
87 def __init__(self, ax, maxt=2, dt=0.02):
94 self.ax.add_line(self.
line)
95 self.ax.set_ylim(-.1, 1.1)
96 self.ax.set_xlim(0, self.
maxt)
99 lastt = self.
tdata[-1]
104 self.ax.figure.canvas.draw()
113 'return a random value with probability p, else 0' 115 v = np.random.rand(1)
119 yield np.random.rand(1)
121 fig, ax = plt.subplots()
125 ani = animation.FuncAnimation(fig, scope.update, emitter, interval=10,