0

I am trying to make an animated plot, which plots the content of my "input" matrix. (input[1,t,x,y,0]=z where x is the x coordinate, y the y coordinate, z the color value and t the time value over which I want to animate my plot)

But when I run the code I only get a static picture of a certain time value. Does anyone have an idea why this is so?

Thanks for any help.

Here is the code:

def plot_fig():
global M

fig = plt.figure(figsize=(5,5))
my_img=plt.imshow(input[1,0,:,:,0],origin='lower',interpolation='nearest',vmin=0.0,vmax=1.0)
plt.colorbar()
plt.axis('off') # no axes

def update(frame_number):
    global t
    global input
    print("update")
    t += 1
    my_img.set_data(input[1,t,:,:,0])
    return my_img

anim = FuncAnimation(fig, update, interval=10)
plt.show()
print("end")
Sebastian
  • 21
  • 4
  • ok thanks, i fixed it. Somehow my code did work as an .py file but not in jupyter notebook. Very weird! I Changed my code a bit so I am opening up a new thread. thanks tho! – Sebastian Mar 21 '18 at 10:52
  • Edit: I also did not get any errors, so i could not post any. Here is my other thread: https://stackoverflow.com/questions/49404585/python-animation – Sebastian Mar 21 '18 at 11:10

0 Answers0