I am trying to generate an animation of this plot with FuncAnimation. Those lines change over time, and that's what I would like to capture with FuncAnimation.
Currently, I can generate an animation, but one single line per subplot.
My code for animation roughly looks like this:
y1 = np.random.rand(1000, 5, 80)
y2 = np.random.rand(1000, 5, 80)
fig, axes = plt.subplots(1 ,2)
lines = []
x = np.linspace(0, 1, 1000)
for index, ax in enumerate(axes.flatten()):
if index == 0:
l, = ax.plot(y1[:,0,0], x)
if index == 1:
l, = ax.plot(y2[:,0,0], x)
lines.append(l)
def run(it):
for index, line in enumerate(lines):
if index == 0:
line.set_data(x, y1[:, 0, it]
if index == 1:
line.set_data(x, y2[:, 0, it]
return lines
ani = animation.FuncAnimation(fig, run, frames =80)
plt.show()
But, again, that code only generates only line per subplot. I'd like to have multiple lines per subplot (in the example code, that would be 5 lines). Does anyone know how do that? I don't have to use my code template, it could be something entirely different.