Created
August 14, 2018 11:16
-
-
Save ceptreee/914f548f0e88e4cf05eda86798a9f49f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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