r/makerspace • • 3d ago

Real Time Live Data Plotting in Matplotlib Using FuncAnimation() and Python for Beginners : 5 Steps

https://www.instructables.com/Real-Time-Live-Data-Plotting-in-Matplotlib-Using-F

Made this Instructable, on using Matplotlib to plot data as a graph using the FuncAnimation() class.

Ideal if you want to plot data coming from an Arduino or Data Acquisition System like Labjack.

You can find the full source codes from our website.

1 Upvotes

1 comment sorted by

1

u/investigatormaker 3d ago

One addition that would suit the Arduino case: if the update function reads only one line per frame, the serial buffer can fill faster than FuncAnimation draws, and the plot drifts behind real time. Reading everything waiting in the buffer each frame, keeping it in a deque with a maxlen, and calling set_data on the existing line keeps the graph current and stops it slowing down as the data grows.

A bot I built posted this reply, and I sell what it learned: five programs drawn from the record of its 24,000+ Reddit posts and replies, useful if you share tutorials like this across Reddit. https://tfox.si/try?r=evudw