Skip to main content

Live pyqtgraph plot

Pglive package adds support for thread-safe live plotting based on pyqtgraph.
It supports PyQt5, PyQt6 and PySide6.

Description

Pyqtgraph doesn't offer easy way to implement live plotting out of the box. The aim of PgLive module is to provide easy way of thread-safe live plotting. To do this, PgLive provides DataConnector object, which consumes data and manages data plotting. DataConnector interface provides Pause and Resume method, update rate and maximum number of plotted points. All that needs to be done is to connect plots and data sources with DataConnector. Once data is collected, DataConnector is sending signals to the GUI main loop.

Focus on data handling - leave plotting to pglive.

You can find many examples for PyQt5, PyQt6 or PySide6.

Code example

import sys
from math import sin
from threading import Thread
from time import sleep

from PyQt6.QtWidgets import QApplication

from pglive.sources.data_connector import DataConnector
from pglive.sources.live_plot import LiveLinePlot
from pglive.sources.live_plot_widget import LivePlotWidget

"""
Line plot is displayed in this example.
"""
app = QApplication(sys.argv)
running = True

plot_widget = LivePlotWidget(title="Line Plot @ 100Hz")
plot_curve = LiveLinePlot()
plot_widget.addItem(plot_curve)
# DataConnector holding 600 points and plots @ 100Hz
data_connector = DataConnector(plot_curve, max_points=600, update_rate=100)


def sin_wave_generator(connector):
    """Sine wave generator"""
    x = 0
    while running:
        x += 1
        data_point = sin(x * 0.01)
        # Callback to plot new data point
        connector.cb_append_data_point(data_point, x)
        sleep(0.01)


plot_widget.show()
# Start sin_wave_generator in new Thread and send data to data_connector
Thread(target=sin_wave_generator, args=(data_connector,)).start()
app.exec()
running = False

Output:

Plot example

To run built-in examples, use python3 -m parameter like:
python3 -m pglive.examples_pyqt6.all_plot_types
python3 -m pglive.examples_pyqt6.crosshair

Using PyQt5/6 designer

  1. Add QWidget to Your layout
  2. Promote QWidget to LivePlotWidget and set header file to pglive.sources.live_plot_widget
  3. Click Add and Promote button

All plot types

Available plot types

Pglive supports four plot types: LiveLinePlot, LiveScatterPlot, LiveHBarPlot (horizontal bar plot), LiveVBarPlot (vertical bar plot) and LiveCandleStickPlot.

All plot types CandleStick plot live-categorized-bar.gif heatmap.gif

Plot speed optimizations

Scaling plot view to plotted data has a huge impact on plotting performance. Re-plotting might be laggy when using high update frequencies and multiple plots.
To increase plotting performance, pglive introduces LiveAxisRange, that can be used in LivePlotWidget. User can specify when and how is a new view of plotted data calculated.

Have a look in the live_plot_range.py example.

Range_optimization

In case you want to plot wider area with LiveAxisRange you can use crop_offset_to_data flag. For example, you want to store 60 seconds, display 30 seconds in a view and move view every 1 second. You will end up with big empty space to the left if crop_offset_to_data = False. Take a look into crop_offset_to_data.py example.

crop_offset_to_data

Introduced in v0.4.0

Crosshair

Pglive comes with built-in Crosshair as well. Take a look at crosshair.py example.

Crosshair

Leading lines

Leading line displays horizontal or vertical line (or both) at the last plotted point.
You can choose its color and which axis value is displayed along with it.
Example at leading_line.py

Leading lines

Axis

To make life easier, pglive includes a few axis improvements:

  • Colored axis line using new axisPen attribute
  • Time and DateTime tick format, converting timestamp into human-readable format
  • Use tick_angle attribute to change tick angle from 0 default degree

Example at axis.py

Axis example

Summary

  • With Pglive You've got an easy Thread-safe live plot implementation in Pyqt5, Pyqt6 or PySide6
  • You can use all kwargs that works in pyqtgraph
  • Use your plots with DataConnector directly
  • It works with Python3.9, 3.10, 3.11 and 3.12 as well
  • Multiple optimized plot types
  • Many examples for easy start

If you find PgLive helpful, please consider supporting me, it helps a lot!
Thanks to all contributors, feel free to suggest missing feature or any bug on GitHub.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pglive-0.9.1.tar.gz (41.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pglive-0.9.1-py3-none-any.whl (78.7 kB view details)

Uploaded Python 3

File details

Details for the file pglive-0.9.1.tar.gz.

File metadata

  • Download URL: pglive-0.9.1.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.9 Darwin/25.6.0

File hashes

Hashes for pglive-0.9.1.tar.gz
Algorithm Hash digest
SHA256 df24b350703469be8f9cf931acec6b72b6572f7aaea43cc7966c290ea955118d
MD5 e75ea469d7df77cbb287b0d4b5d90332
BLAKE2b-256 6cbaf43da9c6a58ddec06b7d9f27e0fdb44e2345aa8e195fe308cf8898ca6fa5

See more details on using hashes here.

File details

Details for the file pglive-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: pglive-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 78.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.9 Darwin/25.6.0

File hashes

Hashes for pglive-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 740be01e23910ed51779089f3d67637e695618698570c6b212418edaf2550859
MD5 63995ce7d2efd3da7865c9aa5b235fbf
BLAKE2b-256 7319b3a1904df6bfdb215b0e126fc510f27172723d201c63453ea74efe4d9035

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.9.1 This release

2 files

0.9.0

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.7

2 files

0.7.6

2 files

0.7.5

2 files

0.7.4

2 files

0.7.3

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.9

2 files

0.6.8

2 files

0.6.7

2 files

0.6.6

2 files

0.6.5

2 files

0.6.4

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.3.3

2 files

0.3.0

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page