I am currently processing some images using numpy and I'm storing the new arrays with the results in dictionaries. An example of the images is below:
Once I have the dictionary with the results, that are also images, how can I make a movie sequence of them? Using this I intend to observe how the structures evolve in time.
My attempt to achieve this is represented below:
import matplotlib.pyplot as plt
def init(img):
    '''
    This function supports the ''make_anim'' function by plotting the
    background of each frame
    '''
    img.set_data([],[])
    return(img)
def updatefig(data, keys, i):
    '''
    This function supports the ''make_anim'' function by refreshing the 
    image space.
    '''
    img.set_data(data[keys[i]])
    return(img)
def make_anim(data, keys = []):
    '''
    This function will produce an animation from a dataset.
    '''
    if keys == []:
        keys = list(data.keys())
    dims = data[keys[0]].shape
    #defining the figure
    fig = plt.figure()
    #defining axis
    ax = plt.axes(xlim=(0, dims[1]), ylim=(0, dims[0]))
    #inserting the dataset to an image
    img = plt.imgshow(data, animated = True)
    #using the animation function
    ani = animation.FuncAnimation(fig, updatefig(data, keys), 
                                  interval = 50,
                                  frames = len(keys), blit = False)
    plt.show()
    return()
I'm struggling to find tutorials that deal with similar problems and when I find them I can't really reproduce.
Thanks for your time in advance!
Andre
