gcalderone/Gnuplot.jl

animation, better quality

Closed this issue · 2 comments

Hello,
the following works, however, the quality is not really good.
I was wondering if there is a way around, by specifying before the kind of *.png images to use for the animation.

using Gnuplot
x = 0:0.01:2*π
@gp xlab = "x" ylab = "sin"
for i in 1:20
    @gp :- i x sin.(x .+ i / 10.0) "w l lc 'black' notit"
end
#@gp :- "set terminal pngcairo"
save(term="gif animate delay 10", output="animation.gif")

I guess this is the best you can get with the gif terminal alone.

Alternatively you can use the pngcairo terminal and then create an animation:

x = 0:0.01:2*π
files = Vector{String}()
for i in 1:20
    @gp xlab = "x" ylab = "sin"  x sin.(x .+ i / 10.0) "w l lc 'black' notit"
    save(term="pngcairo", output="animation$(i).png")
    push!(files, "animation$(i).png")
end
run(`convert -limit memory 1 -limit map 1 $files animation.gif`)
# run(`rm -f $files`)

This works pretty nice!, and it's not too complicated.
Thanks!