High FPS animations in matplotlib

preview_player
Показать описание
See how blitting can be used to increase a matplotlib animation's fps by over 7x.

matplotlib is a plotting library for python, that produces publication quality plots. Unfortunately because they are publication quality, the time taken to set-up and draw the plot can be quite slow.

Typical animation framerates for redrawing plots are in the low/sub 10s. By using the FuncAnimation class along with blitting framerates over 60 fps are achievable.

This video is aimed at undergraduates or anyone interested in python.
Рекомендации по теме
Комментарии
Автор

Thanks, really good explanation! I was trying to improve animation performance myself in the last days, and one thing worth mentioning is that blitting works only with interactive backends, but if you are saving it to a movie it silently reverses to full redraw, which is not documented in FuncAnimation nor Animation classes, and it took me some time to realize by studying sources and debugging. So in that case you need to implement it yourself not relying on FuncAnimation.

curious
Автор

Very nice overview, thanks a lot! My takeaway: fix the limits of axes to fit the final plot since the first frame and just blit away 😅

imotvoksim
Автор

It's great...could you please share the python code?

Rwop
Автор

Great video. Very informative for the tradeoffs of the different approaches!

randacoustics
Автор

Nice to see how you went through the journey... Look at this... .. but if you do it this way So yeah, don't get the UI to plot/scale ... and it's REALLY quick!

originuk
Автор

For something like a simple count you can use a text object inside the canvas and update that.

johnteran
Автор

Great vid cheers. Would the fps be improved by updating more than one line at a time. Currently need to plot sensor data that comes in every 13.5ms but it occured to me i could maybe plot two data points every 27ms? Would this work? I realise it may look less smooth but this way it would only require 37fps to stay real-time right?

fergusjohnstone
Автор

Great information, thanks for sharing!

stevehageman
Автор

Also what is the function getfigax()? can't seem to find documentation on it

fergusjohnstone
Автор

Thank you for your excellent video. On line 103 of your code, is shows lineL.set_data(t[frame], y[frame]) where frame is a single number from range(N). This produces an error. Please tell us why your code functions. Thank you!

electron
Автор

Very invaluable and instructive video. I am making an automatic data logging device using a raspberry pi for my gf for her research work and I was searching for exactly this.

Btw, any idea on how to decouple the data processing logic from the matplotlib gui? I really need to offload the data processing task to a different thread because it hangs the gui and the timings are way off. It is usually advised not to put time consuming code in gui event callbacks (here the events are probably some kind of timer events).

rajatmond
Автор

Friend where is code???

So we can try by our too...

punjaramborhade
Автор

How to kivy metapolt plt.gcf convert plt.show()

aspuser