Skip to content

Instantly share code, notes, and snippets.

@starovoitovs
Last active July 14, 2020 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starovoitovs/a6de7e65291553ad981184a47fa7a6cd to your computer and use it in GitHub Desktop.
Save starovoitovs/a6de7e65291553ad981184a47fa7a6cd to your computer and use it in GitHub Desktop.
GIF animation

GIF animation

Run this command in the directory that contains frames/ directory (needs installed imagemagick)

convert -delay 5 -loop 0 -dispose previous frames/*.png animation.gif
def plot(ax, i):
xs = np.linspace(0, 2 * np.pi, 101)
ax.plot(xs, np.sin(xs + i * 0.1))
for i in range(100):
fig, ax = plt.subplots()
plot(ax, i)
fig.savefig(f"frames/{(i+1):03}.png")
plt.close(fig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment