I wrote the following code based on the matplotlib site example.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig = plt.figure()
nFreqs = 1024
nFFTWindows = 512
viewport = np.ones((nFreqs, nFFTWindows))
im = plt.imshow(viewport, animated=True)
def updatefig(*args):
global viewport
print viewport
viewport = np.roll(viewport, -1, axis=1)
viewport[:, -1] = 0
im.set_array(viewport)
return im,
ani = animation.FuncAnimation(fig, updatefig, interval=50, blit=True)
plt.show()
Before changing the animation works, but now it doesn't. I expected it to start with a purple plot, which slowly turns yellow from the right edge to the left. The viewport variable does update correctly (checked it with print in my function).
I get the static image (all ones, like it was initially):
Where did I go wrong here?
