This article has experienced "This article is more than a year old since it was last updated."
I want to display continuously generated images using matplotlib.animation
. You can do this by creating a function that generates an image and ʻimshowas follows. The reason why I did
plt.clf ()` on the way was that it seemed to get heavier with each step, so I tried to clear it every time.
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
N = 50
fig, ax = plt.subplots()
def update(i):
a = np.uint8(np.random.uniform(0, 255, [N, N, 3]))
a[i:, i:] = 0.
plt.clf()
plt.imshow(a)
hoge = animation.FuncAnimation(fig, update, np.arange(1, N), interval=25) #Will be erased if not assigned
plt.show()
that's all.
Recommended Posts