Skip to content

WilliamLHostetter/live-plotting-matplotlib-python

Repository files navigation

Live plotting with Python using the Matplotlib library

Python implementations of live plotting using the Matplotlib library. When data is collected from a device such as a microcontroller or from the web, it can be plotted in real-time as soon the data is available, allowing you to visualize the data live. The examples provided here are made as simple as possible by representing the input data with random numbers from Python.

Two different methods for creating live plots are available. The first method redraws the plot for every frame and includes timestamp labels for each data point.


The second method, known as blitting, has higher performance by only redrawing the changing data points each frame, while preserving the unchanging background, axes, and axes labels. This involves a trade-off by sacrificing the timestamp labels.

Table of Contents

Prerequisites

Python 3 (tested in version 3.12.2)

Dependencies

The only external dependency for these routines that needs to be installed is the Matplotlib library. Instructions for installing the Matplotlib library can be found on their documentation and installation guide page. You can install Matplotlib with either pip or conda. The pip command is given below.

pip install matplotlib

References

Usage

live-plotting-timestamps.py

This script generates 15 frames of random numbers in the range -0.5 to +0.5 and plots the data every second. It can be ran directly in the console with

python live-plotting-timestamps.py

live-plotting-blitting.py

This script generates 30 frames of random numbers in the range -0.5 to +0.5 and only redraws the graphical elements that change while preserving the unchanging elements. It can be ran directly in the console with It can be ran directly in the console with

python live-plotting-blitting.py

About

Live plotting with Python using the Matplotlib library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages