Dear PlotlyBase community, Is there a way how to get animation from Animations · Plots using pure PlotlyBase package?
Have you checked this PlotlyJS post?
Yes I am aware of this thread, but I am not able to find it there
@PetrKryslUCSD can confirm how he produced the nice animations. From his reply he seems to be using react!
as in code example here.
NB:
As a workaround to save animated GIFs, you may use some nice free open source SW such as ShareX in Windows, Flameshot in Linux, etc.
What exactly do you need? Do you want to use Plots, or would PlotlyJS work for you?
I would like to use pure PlotlyJS to make animation (exported to gif) like this:
anim = @animate for i ∈ 1:n
Plot_st_using_PlotlyJS
end
gif(anim, "anim_fps15.gif", fps = 15)
This works:
using PlotlyJS
layout = Layout(width = 500, height = 500)
layout[:title] = ""
layout[:showSendToCloud] = true
layout[:showLegend] = true
layout[:showEditInChartStudio] = true
f(frame) = if frame < 10; "0$frame"; else "$frame"; end
frame = 1
xyz = rand(frame, 3)
plots = cat(scatter3d(;x=xyz[:, 1],y=xyz[:, 2], z=xyz[:, 3], mode="markers",
marker=attr(color="red", size=1, symbol="circle",
line=attr(color="red", width=1))), dims = 1)
pl = plot(plots, layout;
options=Dict(:showLink => true, :toImageButtonOptions => Dict(:format=>"webp")))
display(pl)
let
for frame in 1:10
xyz = rand(10*frame+10, 3)
plots = cat(scatter3d(;x=xyz[:, 1],y=xyz[:, 2], z=xyz[:, 3], mode="markers",
marker=attr(color="red", size=3, symbol="circle",
line=attr(color="red", width=1))), dims = 1)
react!(pl, plots, pl.plot.layout)
sleep(0.5)
savefig(pl, "a$(f(frame)).png")
end
end
# Convert to a gif
# magick a*.png a.gif
Note that i use ImageMagick to convert the frames into an animation.
2 Likes
Thank you