Gadfly.jl
Gadfly.jl copied to clipboard
[Feature offer] Animations in Gadfly
Hi 👋
First of all, thanks for the amazing work on this library, I'm a big fan and use it every day!
I wanted to create some animation (= GIFs) in Gadfly and realized that there is no easy way to do this at the moment, so I created a simplified version of the Plots.jl implementation (https://github.com/JuliaPlots/Plots.jl/blob/master/src/animation.jl). It is very close to the Plots.jl implementation with some small changes for it to be usable with Gadfly.
Here the working Gist for it: https://gist.github.com/matthieubulte/b1f979220ed6db8e1b4debd1c319bc7f
Would you be interested in a PR for this? If yes, is Gadfly the right repo for this, or would Compose be a better location for this code? If yes, and Gadfly is the right place for this, I would be happy to have some guidance on making this PRable.
Cheers
that's cool! i did not know about the animation script in Plots.jl.
i hesitate to fork a copy in to Gadfly as the commit history on the one in Plots shows that it's under active development. and so the fork here wouldn't get the benefit of continued bug fixes and new features.
i notice that very little has to change to get it to work for Gadfly. do you think a separate package could be created, say Animations.jl, which was agnostic to whether Plots or Gadfly or Makie or Winston or UnicodePlots or whatever was used? that would be really useful.
Hi Ben,
i hesitate to fork a copy in to Gadfly
I also have mixed feelings about this, for other reasons.
commit history on the one in Plots shows that it's under active development
I'm not sure I would call this active, but you're right that having almost the same code in two repos is maybe not the best option.
do you think a separate package could be created, say Animations.jl, which was agnostic I really like the idea! Makie seems to already support animated plots, in a way which I think could not be re-used or adapted to the kind of animation API that Plots has. Maybe a good starting point is a small library supporting Plots and Gadfly.
The issue I have is that we have two "competing" approaches to plotting. On the one hand, Plots is based on a global plot object that is being mutated, and so the animation loop body doesn't need to return a plot object for each frame (see https://github.com/JuliaPlots/Plots.jl/blob/master/src/animation.jl#L227). On the other hand, and to my understanding, Gadfly is based on composing "plotting objects" (that's what I like about it!), so the body of the animation loop would have to return the current frame.
The only I can imagine to bring together these two approaches -- without having to ask the user to specify which library their using -- is to try to automatically recognize which plotting library is being used. But this feels hacky and will probably lead to issues down the line.
Any recommendation?
if Plots follows Base's convention of having push!
return the mutated collection, then the animation loop body should return a plot object. i don't use Plots so don't know if this is true or not though.