animate にした gif を複数のグラフに同時出力(伝われ)

Home   »   animate にした gif を複数のグラフに同時出力(伝われ)

print(versioninfo())

using Plots
using LaTeXStrings

f(x) = sin.(x)
g(x) = cos.(x)

x = -π:0.1:π

p1 = plot(x,f)
p2 = plot(x,g)

plot(p1,p2,layout=(2,1))

p1 = plot()
p2 = plot()
p3 = plot()
p4 = plot()

anim = @animate for a in 0:5
    for b in 0:3 #ここに書いたbはanimateに直接作用しない?
        f(x) = sin.(a*x) + b
        g(x) = cos.(b*x) + a
        p1 = plot!(p1,x,f,label="a=$a,b=$b")
        p2 = plot!(p2,x,g,label="b=$b,a=$a")
        p3 = plot!(p3,x,f,label="sin($a x) + $b")
        p4 = plot!(p4,x,g,label="cos($b x) + $a")
        plot(p1,p2,p3,p4,layout=(4,1))
    end
end

gif(anim,"output.gif",fps=10)

Leave a Reply

Your email address will not be published. Required fields are marked *