Say I have a function plot(I) to plot an image like
def plot(I):
plt.imshow(I)
time.sleep(0.5)
plt.show(block=False)
And in my main program, I have a loop to update I like
if __name__ == "__main__":
I=some_input
for i in range(300):
I=update(I)
plot(I)
I want to display the updated images like a gif file but the code above failed like the plot does not update and I have to close the window so that it can be updated. Is there any way to achieve what I want like display images consecutively with matplotlib.