Skip to content

Instantly share code, notes, and snippets.

@ceptreee
Created August 14, 2018 11:16
Show Gist options
  • Save ceptreee/914f548f0e88e4cf05eda86798a9f49f to your computer and use it in GitHub Desktop.
Save ceptreee/914f548f0e88e4cf05eda86798a9f49f to your computer and use it in GitHub Desktop.
using PyPlot
using PyCall
@pyimport matplotlib.animation as anim
dx = 0.05
xlm = [0, 2π]
x = collect(xlm[1]:dx:xlm[2])
n = length(x)
y = sin.(x)
fig = figure(figsize=(4, 4))
line = plot([],[])[1]
xlim(xlm)
ylim([-1,1])
function update(i)
line[:set_data](x[1:i],y[1:i])
end
myanim = anim.FuncAnimation(fig, update, frames=n, interval=30)
@time myanim[:save]("anim.mp4", writer="ffmpeg")
# @time myanim[:save]("anim.gif", writer="imagemagick")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment