Skip to main content

Reusable PySide6/PyQtGraph live plotting widget with toolbar, legend, and smart axis formatting.

Project description

PyQtLabGraph

PyPI version Supported Python versions License: MIT

A powerful, interactive, and premium live plotting library for PySide6/Qt6, based on PyQtGraph.

PyQtLabGraph is built for both interactive scientific data analysis and high-performance real-time visualization, providing an embeddable plot widget, dedicated toolbars, external legend layouts, smart axis formatting, layout persistence, and modern, explicit visual themes.

Previews

Light Theme (Default) Dark Theme
PyQtLabGraph Light Theme PyQtLabGraph Dark Theme
Modeless Customize Dialog Modular Widget Layout
PyQtLabGraph Customize Dialog PyQtLabGraph Modular Layout Diagram
[1] Plot Widget โ€ข [2] External Legend Widget โ€ข [3] Plot Toolbar Widget

Why PyQtLabGraph? (Aesthetic & Usability Philosophy)

In scientific and engineering environments, two plotting libraries dominate the Python ecosystem:

  • Matplotlib: Unrivaled for generating static, publication-quality figures, but often heavy or sluggish when handling interactive real-time telemetry or rapid live data streams.
  • PyQtGraph: An exceptionally fast, graphics-hardware-accelerated library built for high-performance plotting, but one that deliberately leaves user-interface chrome (like toolbars, legends, customize dialogs, and layout persistence) to be implemented by the developer from scratch.

PyQtLabGraph bridges this gap. It is designed as a high-productivity, instrument-grade plotting interface that brings the ease of use of traditional graphical programming environments to Python.

Many scientists, laboratory engineers, and researchers are familiar with the instant, out-of-the-box utility of instruments and classic engineering software platforms (such as LabVIEW), where plotting components come pre-packaged with zoom controls, custom legends, scaling tools, and runtime style editors. PyQtLabGraph delivers this exact workflow in a clean, pythonic PySide6 package:

  • Familiar, Hardware-Like Controls: The interface mimics the look, feel, and rapid utility of physical lab instruments (e.g., oscilloscopes, analyzers) and classic instrumentation software.
  • Instant Interactive Zooming & Panning: Features intuitive mouse bindings (wheel zoom, key-constrained zooms) and double-click axis inputs out-of-the-box.
  • Rich Quality-of-Life (QoL) Features: Includes a dedicated toolbar (X/Y locked zoom, autoscaling, live rolling window), a modeless live-preview Customize dialog, and complete JSON layout persistence.
  • Modern Aesthetic Themes: Sleek, built-in themes (light, dark, solarized) independent of OS-level dark-mode checks, adapting naturally to the host application's active Qt stylesheet.
  • Modular Widget Architecture & Qt Designer Support: The plot canvas, toolbar, and legend are decoupled into three independent QWidgets. You can lay them out freely or drag and size placeholder containers inside Qt Designer, letting PyQtLabGraph mount itself automatically.

Features

  • Real-Time Plotting: High-performance rendering optimized for rapid updates, live sensor streams, or fast oscilloscope-style displays.
  • Smart Axis Formatting (SmartAxisItem):
    • AUTO: Automatic SI-prefix scaling (e.g., scaling raw Hertz to kHz / MHz / GHz).
    • LINEAR: Explicit raw values with user-defined units, bypassing auto-scaling.
    • TIME: Adaptive relative time formatting displaying seconds formatted elegantly as d h min s depending on zoom level.
  • Dedicated External Legend (PyQtLabGraphLegend):
    • Displays curve symbols, colors, and labels.
    • Interactive: Double-click a curve's legend item to open the Customize dialog immediately focused on that curve. Single-click to toggle curve visibility.
    • Configurable orientation: Can be placed vertically (default) or horizontally.
  • Integrated Toolbar:
    • Action buttons for Show All, rectangle zoom, X-zoom, and Y-zoom.
    • Quick autoscale toggle for X and Y axes individually.
    • Rolling X-range display with custom size configuration.
    • Live PNG export and instant Customize dialog access.
  • Modeless Customize Dialog:
    • Adjust titles, labels, units, and axis formatting modes.
    • Toggle grids, global anti-aliasing, downsampling, clip-to-view, and adaptive performance.
    • Manage individual curves: toggling visibility, line width, line colors, marker styles (circle, square, cross, diamond, etc.), size, and borders.
    • Live Preview: All configuration edits preview immediately in the plot in real-time, and revert instantly if the user clicks Cancel.
  • Layout Persistence: Save/Load all layout configurations (visual properties, themes, active ranges, curve states) to a shared versioned JSON file.
  • Adaptive Performance: Automatic visual simplification when rendering very dense datasets to avoid UI lag.

Interactive Controls

PyQtLabGraph introduces advanced viewport mouse controls on top of the standard PyQtGraph mouse interactions:

  • Mouse Drag (Left Click): Pans the view in the selected tool mode.
  • Mouse Drag (Right Click): Zooms X and Y scale dynamically (drag left/right for X, up/down for Y).
  • Mouse Wheel: Zooms both X and Y axes centered on the cursor position.
  • Shift + Mouse Wheel: Zooms X-axis only, preserving the Y-axis range.
  • Ctrl + Mouse Wheel: Zooms Y-axis only, preserving the X-axis range.
  • Double Click Axis: Opens a quick manual range pop-up directly underneath the cursor for entering exact values.

Installation

Install PyQtLabGraph from PyPI:

pip install pyqtlabgraph

Or install it directly from the repository source:

pip install .

For development installations, make sure you have the runtime dependencies installed:

pip install PySide6 pyqtgraph

Quick Start

Here is a minimal working example of embedding the PyQtLabGraphWidget inside a basic Qt window:

import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout
from pyqtlabgraph import PyQtLabGraphWidget

app = QApplication(sys.argv)
window = QMainWindow()
central = QWidget()
layout = QVBoxLayout(central)
window.setCentralWidget(central)

# Initialize the plot widget
plot = PyQtLabGraphWidget(
    plot_container=central,
    plot_identifier="quickstart_plot",
    show_toolbar=True
)

# Plot a simple sensor temperature curve
plot.plot(
    key="temp_sensor",
    x=[0, 1, 2, 3, 4, 5],
    y=[22.1, 22.4, 23.0, 22.8, 23.5, 24.1],
    label="Temperature",
)

# Set axis labels and units
plot.set_axis_labels(
    x_label="Time", x_units="s",
    y_label="Temperature", y_units="ยฐC"
)

window.resize(800, 600)
window.show()
sys.exit(app.exec())

To see more complex features, run the bundled examples:

  • Thermostat Simulation Demo:
    python examples/demo_thermostat.py
    
  • Time Domain & FFT Demo:
    python examples/demo_time_fft.py
    
  • Host Application Styling Comparison:
    python examples/demo_thermostat_qdarktheme.py
    

Detailed Documentation


Project Structure

โ”œโ”€โ”€ pyqtlabgraph/            # Main library package
โ”‚   โ”œโ”€โ”€ __init__.py          # Public exports & versioning
โ”‚   โ”œโ”€โ”€ widget.py            # Main PyQtLabGraphWidget and API wrapping
โ”‚   โ”œโ”€โ”€ dialogs.py           # Modeless Customize dialog & popups
โ”‚   โ”œโ”€โ”€ layouts.py           # JSON Layout save/load mechanics
โ”‚   โ”œโ”€โ”€ toolbar.py           # Toolbar buttons, export, and mode controllers
โ”‚   โ”œโ”€โ”€ legend.py            # External interactive PyQtLabGraphLegend
โ”‚   โ”œโ”€โ”€ axis.py              # SmartAxisItem tick formatting implementation
โ”‚   โ”œโ”€โ”€ models.py            # Core dataclasses (CurveState, InteractionState)
โ”‚   โ”œโ”€โ”€ styles.py            # Curve style configurations and palettes
โ”‚   โ”œโ”€โ”€ themes.py            # Background themes and color registries
โ”‚   โ”œโ”€โ”€ qt_styles.py         # Standard fallback borders and QSS wrappers
โ”‚   โ””โ”€โ”€ assets/              # PNG icon assets used by the toolbar
โ”œโ”€โ”€ docs/                    # Detailed user-facing documentation
โ”œโ”€โ”€ tests/                   # Standalone smoke test suite
โ”œโ”€โ”€ examples/                # Packaged demo and example files
โ””โ”€โ”€ pyproject.toml           # Build system and package metadata

Development & Verification

Tests are located in the tests/ directory and can be executed via a unified test runner. Run this command after any code changes to verify syntax, assets, and UI state:

python3 tests/run_smoke_checks.py

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

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

Source Distribution

pyqtlabgraph-0.1.1.tar.gz (265.3 kB view details)

Uploaded Source

Built Distribution

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

pyqtlabgraph-0.1.1-py3-none-any.whl (265.6 kB view details)

Uploaded Python 3

File details

Details for the file pyqtlabgraph-0.1.1.tar.gz.

File metadata

  • Download URL: pyqtlabgraph-0.1.1.tar.gz
  • Upload date:
  • Size: 265.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyqtlabgraph-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4533ec36e53fb3e76a863425be566f1be0c4939ac90708617ff23baccbc5a6f9
MD5 b8ea7c2237f523516e2ec2e8860bce13
BLAKE2b-256 15dd3c997e1b262587e67f4f6b9979bc56717edca6c3db537e861fa0bdd67898

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyqtlabgraph-0.1.1.tar.gz:

Publisher: publish.yml on choberg/pyqtlabgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyqtlabgraph-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyqtlabgraph-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 265.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyqtlabgraph-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3195fcaa63d678a2346147aef97b7dd59da344f9cc7331ab0b4deefdb8683767
MD5 a501fcafe50a277703b6c637cfa58684
BLAKE2b-256 b35c63081596b06976e353e550cd3e22f5e5f623714a44bc0a4608bc1e941168

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyqtlabgraph-0.1.1-py3-none-any.whl:

Publisher: publish.yml on choberg/pyqtlabgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page