Animations in Python with Matplotlib

preview_player
Показать описание

In this particular example, frames is a sequence with a step size of 50 and the parameter i tells func which parts of the data to plot for a particular frame. There is one more function called init_func, which is optional but it is important, especially for repeating animations. init_func is called at the beginning of the animation and whenever the animation repeats. So it has to reset the initial state of the figure.
That's it. Let me know if you have questions about animations with Matplotlib.

Example code from this video:

Here is an animation I made with Matplotlib:

FuncAnimation docs:
Рекомендации по теме
Комментарии
Автор

Hi I typed in this exact code and FuncAnimation just did nothing. Neither the initialization nor the update function ever ran and all I got was an empty plot. It might have something to do with Jupyter notebook, is that a problem?

benjaminschocket-greene
Автор

Thanks for the video, I have a question .. how did you download ffmpeg ? I can't find how to add it to my Anaconda version ...

loisbrld
Автор

just what I was looking for :) A relatively barebones example. I installed ffmpeg with chocolatey to make it work

chikkenvoicesinmyhed
Автор

tried withe the very same code, showing error like ffmpeg not available and list index out of range

writabratadey
Автор

sir tell me how to save file i tried but i could not do

mathanimation
Автор

Thank you very much for the clear explanation. I am really new to python and spyder, could you tell me how to set the plots so they open in a new window, right now they only appear in the console and the plot pane and I am not able to see the animation, it is static, unless I save it. Thank you again.

lucindaamicis
Автор

Can we use the same way for a 3-dimensional function?

mehmetkrtsoglu
Автор

Why use dark theme. Nothing is visible.

shouvikdutta