Edit: My question is not about the "animation" as such. My question here is simply about how to constantly show a new inline image in a for loop on an Ipython laptop.
In essence, I would like to show the updated image in the same place inside, and update it in a loop to show. So my code looks something like this:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from IPython import display
%matplotlib inline
fig, ax = plt.subplots(nrows = 1, ncols = 1, figsize=(10, 10))
for ii in xrange(10):
im = np.random.randn(100,100)
ax.cla()
ax.imshow(im, interpolation='None')
ax.set_title(ii)
plt.show()
The problem is that at the moment it's just ..., well, it shows the first image, and then it never changes.
Instead, I would just like to show the updated image at each iteration embedded in the same place. How should I do it? Thank.
source
share