Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animate in Jupyter notebook #22777

Closed
mforets mannequin opened this issue Apr 7, 2017 · 12 comments
Closed

Animate in Jupyter notebook #22777

mforets mannequin opened this issue Apr 7, 2017 · 12 comments

Comments

@mforets
Copy link
Mannequin

mforets mannequin commented Apr 7, 2017

The animate command allows to animate a list of frames by creating a sage.plot.animate.Animation object.

In a Jupyter notebook environment, the code below returns Animation with 20 frames, while it should have a similar behaviour as with the sage notebook (displaying a gif).

f(x) = 5*x - x^2/8 + x^3/1200
df(x) = diff(f(x),x)
max = 100
p = plot(f(x),x,0,max)
lblp = text("$y = " + latex(f(x)) + "$",[40,100],fontsize=14)
lbldp = text("$y' = " + latex(df(x)) + "$",[40,80],fontsize=14,rgbcolor='#006000')
ga = []
for argx in srange(0,max,5):
    dp = plot(f(argx) + (df(argx)*(x-argx)),x,0,max,color="#006000")
    xp = point((argx,f(argx)),rgbcolor='#800000')    
    ga.append(p+lblp+lbldp+dp+xp)
animate(ga,ymin=0,ymax=max,axes_labels=['x','y'],fontsize=12,figsize=(4,3)).show(delay=1)

Reported in Animation doesn't work by cybervigilante.

Probably intersecting #16573, #16650 and #17783.

CC: @kcrisman

Component: notebook

Keywords: animate jupyter plot

Author: Jeroen Demeyer, Volker Braun

Branch/Commit: cbf2b37

Reviewer: Marcelo Forets

Issue created by migration from https://trac.sagemath.org/ticket/22777

@mforets mforets mannequin added this to the sage-8.0 milestone Apr 7, 2017
@mforets mforets mannequin added c: graphics labels Apr 7, 2017
@mforets

This comment has been minimized.

@jdemeyer
Copy link

Author: Jeroen Demeyer

@jdemeyer

This comment has been minimized.

@vbraun
Copy link
Member

vbraun commented Jun 23, 2017

comment:5

Last time I checked jupyter didn't support gif (hence no animated gif either).

@kcrisman
Copy link
Member

comment:6

But see also this post about mpl html5 animations. Various other workarounds of varying quality are out there ... and there is even a request.

@vbraun
Copy link
Member

vbraun commented Jun 25, 2017

Branch: u/vbraun/animate_in_jupyter_notebook

@vbraun
Copy link
Member

vbraun commented Jun 25, 2017

comment:8

The patch adds GIF support to the jupyter notebook.

Actual html5 video would be better, but also requires some encoder like ffmpeg. Whereas I think we can generate animated gif without external dependencies.

Of course you don't have to call animate(...).show(), the displayhook already renders the animation if it can. Really its our fault for having that confusingly-named show() method.


New commits:

cbf2b37Add GIF support to the Jupyter notebook display backend

@vbraun
Copy link
Member

vbraun commented Jun 25, 2017

Commit: cbf2b37

@vbraun
Copy link
Member

vbraun commented Jun 25, 2017

Changed author from Jeroen Demeyer to Jeroen Demeyer, Volker Braun

@mforets
Copy link
Mannequin Author

mforets mannequin commented Jun 25, 2017

Reviewer: Marcelo Forets

@mforets
Copy link
Mannequin Author

mforets mannequin commented Jun 25, 2017

comment:11

looks good to me.

PS: in my (Mac osx) machine, animate produces ugly yellowish axes, see screenshot and gif. but i think this has nothing to do with the jupyter notebook itself..

@vbraun
Copy link
Member

vbraun commented Jun 26, 2017

Changed branch from u/vbraun/animate_in_jupyter_notebook to cbf2b37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants