Re: matplotlib & animations

104 views
Skip to first unread message

LFS

unread,
Jan 19, 2013, 1:31:15 PM1/19/13
to sage-s...@googlegroups.com
Hi - I am like the a total amateur with sage, but here is a page that I did with animation - credit: Nils Brun
http://sage.math.canterbury.ac.nz/home/lfahlberg/58/  I see it is still working. It has 5-6 plots so with the current java problems, be prepared to click on Run a gazillion times.
The animation is 2nd to last thing. Best, Linda

On Thursday, 17 January 2013 06:41:14 UTC+1, David Morawski wrote:
I'm having some troubles figuring out matplotlib from within Sage. I'm interested in doing some animations, so I started with the first example on matplotlib.org. I downloaded the source code for the example and ran the following:

sage: load('animate_decay.py')
sage: plt.savefig('blah.png')

Unfortunately, blah.png contained nothing more than a blank Cartesian plane. I also typed in the code into the sage interpreter "by hand" and had the same output.

Thoughts? Any help and/or directing toward documentation would be most appreciated. I've spent a fair amount of time searching around, but am struggling with matplotlib, in general.


LFS

unread,
Jan 19, 2013, 1:33:45 PM1/19/13
to sage-s...@googlegroups.com
P.S. the animation iterates 5 times and stops (you can see the code iterations=5) so if the point stops moving before you get all there, just change the number or reload. :)

John H Palmieri

unread,
Jan 19, 2013, 2:36:21 PM1/19/13
to sage-s...@googlegroups.com


On Wednesday, January 16, 2013 9:41:14 PM UTC-8, David Morawski wrote:
I'm having some troubles figuring out matplotlib from within Sage. I'm interested in doing some animations, so I started with the first example on matplotlib.org. I downloaded the source code for the example and ran the following:

sage: load('animate_decay.py')
sage: plt.savefig('blah.png')


Instead:

    sage: from animate_decay import *
    sage: ani.save('blah.mp4')

or

    sage: ani.save('blah.avi')

(Can you store animations in png files?)

--
John

Dima Pasechnik

unread,
Jan 20, 2013, 1:31:30 AM1/20/13
to sage-s...@googlegroups.com
On 2013-01-19, John H Palmieri <jhpalm...@gmail.com> wrote:
> ------=_Part_158_32247560.1358624181276
> Content-Type: text/plain; charset=ISO-8859-1
>
>
>
> On Wednesday, January 16, 2013 9:41:14 PM UTC-8, David Morawski wrote:
>>
>> I'm having some troubles figuring out matplotlib from within Sage. I'm
>> interested in doing some animations, so I started with the first example<http://matplotlib.org/examples/animation/animate_decay.html>on
>> matplotlib.org. I downloaded the source code<http://matplotlib.org/examples/animation/animate_decay.py>for the example and ran the following:
>>
>> sage: load('animate_decay.py')
>> sage: plt.savefig('blah.png')
>>
>
>
> Instead:
>
> sage: from animate_decay import *
> sage: ani.save('blah.mp4')

yep, this works just fine!

David Morawski

unread,
Jan 20, 2013, 11:05:10 PM1/20/13
to sage-s...@googlegroups.com
Thanks, John. That worked just fine for me. After posting, I realized PNG was my problem, but none of the other formats compatible with savefig are animate-able either, so I was at a loss.

Linda, I wasn't able to access your notebook.

It would be great if there were a help document/tutorial dedicated solely to using Sage in conjunction with matplotlib(/scipy/numpy?), but I suppose that's a conversation for another thread. Perhaps I'll write it...after I figure it out. Or maybe I'll decide it's superfluous.

LFS

unread,
Jan 21, 2013, 2:24:03 AM1/21/13
to sage-s...@googlegroups.com
http://sage.math.canterbury.ac.nz/home/pub/246  (Sorry posted notebook and not published version.)
Reply all
Reply to author
Forward
0 new messages