PyQtGraph

0.14.0 · active · verified Sun Apr 12

PyQtGraph is an open-source Python library for scientific graphics and GUI development, built on top of Qt and NumPy. It provides fast, interactive plotting for large datasets, signal/image processing, and sophisticated GUI elements, making it ideal for scientific and engineering applications. The current version is 0.14.0, and it maintains a relatively active release cadence with several minor and patch releases per year.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a basic line plot using PyQtGraph. It sets up a QApplication, creates a `GraphicsLayoutWidget` as the main window, adds a plot item, and plots a simple list of data. Crucially, it uses `pg.mkQApp` for application initialization and `app.exec_()` to start the Qt event loop, allowing the GUI to run.

import pyqtgraph as pg
from pyqtgraph.Qt import QtWidgets

# Always start by creating a QApplication
app = pg.mkQApp("PyQtGraph Quickstart")

# Create a GraphicsLayoutWidget (a window to hold plots)
win = pg.GraphicsLayoutWidget(show=True, title="Basic Plot")
win.resize(800, 500)
win.setWindowTitle('PyQtGraph Quickstart Example')

# Enable antialiasing for prettier plots
pg.setConfigOptions(antialias=True)

# Add a plot item to the window
p = win.addPlot(title="Simple Line Plot")

# Generate some data
data = [1, 5, 2, 4, 3, 8, 9, 1, 2, 3, 5]

# Plot the data
p.plot(data)

# Start the Qt event loop if running as a script
if __name__ == '__main__':
    QtWidgets.QApplication.instance().exec_()

view raw JSON →