Code to create a GIF image from py plots

Categories: Uncategorized

def save_img(d, c, i):
    c = np.array(c)
    fname = "/Users/muthukrishnan/Pictures/foo"+str(i)+".png"
    fig, ax = plt.subplots()
    ax.scatter(d[:,0], d[:,1], c='b')
    ax.plot(c[:,0], c[:,1], c='g')
    plt.savefig(fname)
    return fname

#######

filenames.append(save_img(datapoints_angles, convex_hull, i))

######

import imageio
images = []
for filename in filenames:
    images.append(imageio.imread(filename))

imageio.mimsave('/Users/muthukrishnan/Pictures/movie.gif', images)