I have been trying to use pyplot/matplotlib to show images as they change in a loop, but i haven't been able to get anything working. I am basically unable to update the image being shown. here is the code to replicate the problem:
f = plt.figure(1)
ax = plt.gca()
show_obj= ax.imshow(np.random.randn(28,28))
for i in range(10):
print(i)
# None of these 3 options work
if True:
# the image does not update
show_obj.set_data(np.random.randn(28,28))
f.canvas.draw()
if False:
# image does not update
ax.clear()
ax.imshow(np.random.rand(28,28))
pass
if False:
# starts drawing new axes
f = plt.figure(1)
ax = plt.gca()
ax.imshow(np.random.rand(28,28))
plt.show()