pyqtgraph
Fast data visualization and GUI tools for scientific / engineering applications
Top Related Projects
matplotlib: plotting with Python
The interactive graphing library for Python :sparkles:
Interactive Data Visualization in the browser, from Python
Statistical data visualization in Python
Main repository for Vispy
With Holoviews, your data visualizes itself.
Quick Overview
PyQtGraph is a pure-Python graphics and GUI library built on PyQt/PySide and NumPy. It is designed for fast, interactive scientific and engineering applications, providing a flexible and powerful set of tools for data visualization and analysis.
Pros
- Fast performance for real-time data visualization and large datasets
- Highly customizable and extensible plotting system
- Seamless integration with NumPy for efficient data handling
- Wide range of plot types and widgets for scientific and engineering applications
Cons
- Steeper learning curve compared to some other plotting libraries
- Documentation can be sparse in some areas
- Dependency on PyQt/PySide, which may not be ideal for all projects
- Less aesthetically polished out-of-the-box compared to libraries like Matplotlib
Code Examples
- Creating a simple line plot:
import pyqtgraph as pg
import numpy as np
x = np.linspace(0, 10, 1000)
y = np.sin(x)
plt = pg.plot(x, y, title="Simple Line Plot")
- Creating an interactive scatter plot:
import pyqtgraph as pg
import numpy as np
data = np.random.normal(size=(1000, 2))
scatter = pg.ScatterPlotItem(size=10, pen=pg.mkPen(None), brush=pg.mkBrush(255, 255, 255, 120))
scatter.addPoints(data)
plt = pg.plot()
plt.addItem(scatter)
- Creating a real-time updating plot:
import pyqtgraph as pg
import numpy as np
class RealtimePlotter:
def __init__(self):
self.app = pg.mkQApp()
self.plt = pg.plot()
self.curve = self.plt.plot(pen='y')
self.data = np.random.normal(size=100)
self.timer = pg.QtCore.QTimer()
self.timer.timeout.connect(self.update)
self.timer.start(50)
def update(self):
self.data[:-1] = self.data[1:]
self.data[-1] = np.random.normal()
self.curve.setData(self.data)
def run(self):
self.app.exec_()
RealtimePlotter().run()
Getting Started
To get started with PyQtGraph, first install it using pip:
pip install pyqtgraph
Then, import the library and create a simple plot:
import pyqtgraph as pg
import numpy as np
# Create some data
x = np.linspace(0, 10, 1000)
y = np.sin(x)
# Create a plot window and display the data
plt = pg.plot(x, y, title="My First PyQtGraph Plot")
# Start the Qt event loop
if __name__ == '__main__':
pg.mkQApp().exec_()
This will create a window with a simple sine wave plot. From here, you can explore more complex plot types and widgets provided by PyQtGraph.
Competitor Comparisons
matplotlib: plotting with Python
Pros of matplotlib
- Extensive documentation and large community support
- Wide range of plot types and customization options
- Better support for publication-quality figures
Cons of matplotlib
- Slower performance for real-time plotting and large datasets
- More complex API, steeper learning curve for beginners
Code Comparison
matplotlib:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.plot(x, y)
plt.show()
pyqtgraph:
import pyqtgraph as pg
import numpy as np
x = np.linspace(0, 10, 100)
y = np.sin(x)
plt = pg.plot(x, y)
Summary
matplotlib offers a comprehensive plotting library with extensive documentation and a wide range of plot types, making it suitable for creating publication-quality figures. However, it can be slower for real-time plotting and has a steeper learning curve.
pyqtgraph, on the other hand, excels in performance for real-time plotting and large datasets, with a simpler API that's easier for beginners to grasp. It may not offer as many plot types or customization options as matplotlib, but it's well-suited for interactive and scientific applications requiring fast rendering.
The interactive graphing library for Python :sparkles:
Pros of plotly.py
- Interactive and web-based plots, suitable for sharing and embedding
- Wide range of chart types and customization options
- Supports both static and dynamic data visualization
Cons of plotly.py
- Slower rendering for large datasets compared to pyqtgraph
- Steeper learning curve for beginners
- Requires internet connection for some features (CDN-based rendering)
Code Comparison
plotly.py:
import plotly.graph_objects as go
fig = go.Figure(data=go.Scatter(x=[1, 2, 3], y=[4, 5, 6]))
fig.show()
pyqtgraph:
import pyqtgraph as pg
plt = pg.plot([1,2,3], [4,5,6])
pg.QtGui.QApplication.exec_()
pyqtgraph offers a more straightforward approach for simple plots, while plotly.py provides more customization options but requires more setup. plotly.py generates interactive web-based plots, whereas pyqtgraph creates desktop-based visualizations.
Interactive Data Visualization in the browser, from Python
Pros of Bokeh
- Web-based: Generates interactive visualizations for web browsers
- Versatile: Supports a wide range of plot types and customizations
- Large community: More extensive documentation and community support
Cons of Bokeh
- Performance: Can be slower for large datasets or real-time plotting
- Learning curve: More complex API compared to PyQtGraph
- Dependencies: Requires additional libraries for full functionality
Code Comparison
PyQtGraph:
import pyqtgraph as pg
plot = pg.plot()
plot.plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25])
Bokeh:
from bokeh.plotting import figure, show
p = figure()
p.line([1, 2, 3, 4, 5], [1, 4, 9, 16, 25])
show(p)
Summary
PyQtGraph is better suited for desktop applications and real-time plotting, while Bokeh excels in creating web-based visualizations with a wider range of plot types. PyQtGraph offers better performance for large datasets, but Bokeh provides more extensive documentation and community support. The choice between the two depends on the specific requirements of your project, such as target platform, performance needs, and desired visualization types.
Statistical data visualization in Python
Pros of Seaborn
- High-level interface for creating statistical graphics
- Built-in themes for attractive and professional-looking plots
- Seamless integration with pandas DataFrames
Cons of Seaborn
- Limited interactivity compared to PyQtGraph
- Slower performance for large datasets or real-time plotting
- Less flexibility for custom, low-level plot customization
Code Comparison
Seaborn:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_theme(style="darkgrid")
tips = sns.load_dataset("tips")
sns.scatterplot(x="total_bill", y="tip", data=tips)
plt.show()
PyQtGraph:
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
app = QtGui.QApplication([])
win = pg.GraphicsLayoutWidget()
plot = win.addPlot()
scatter = pg.ScatterPlotItem(size=10, pen=pg.mkPen(None), brush=pg.mkBrush(255, 255, 255, 120))
plot.addItem(scatter)
win.show()
app.exec_()
Seaborn excels in creating statistical visualizations with minimal code, while PyQtGraph offers more control over interactive and real-time plotting. Seaborn is better suited for data exploration and static visualizations, whereas PyQtGraph is ideal for applications requiring dynamic, responsive plots.
Main repository for Vispy
Pros of Vispy
- Utilizes modern OpenGL for high-performance 2D and 3D visualization
- Supports a wider range of visualization types, including 3D graphics
- More flexible and customizable for complex scientific visualizations
Cons of Vispy
- Steeper learning curve due to its lower-level API
- Less mature and potentially less stable compared to PyQtGraph
- Smaller community and fewer readily available examples
Code Comparison
PyQtGraph example:
import pyqtgraph as pg
plot = pg.plot()
plot.plot([1, 2, 3, 4, 5], [1, 4, 2, 3, 5])
Vispy example:
from vispy import app, scene
canvas = scene.SceneCanvas()
view = canvas.central_widget.add_view()
line = scene.Line(pos=np.array([(1, 1), (2, 4), (3, 2), (4, 3), (5, 5)]))
view.add(line)
app.run()
Both libraries offer powerful visualization capabilities, but Vispy provides more advanced features for complex graphics at the cost of simplicity. PyQtGraph is generally easier to use for basic plotting tasks, while Vispy excels in performance-critical and advanced visualization scenarios.
With Holoviews, your data visualizes itself.
Pros of HoloViews
- High-level API for quick and easy data visualization
- Seamless integration with Bokeh for interactive web-based plots
- Supports a wide range of data formats and plot types
Cons of HoloViews
- Steeper learning curve for customizing complex visualizations
- Performance may be slower for large datasets compared to PyQtGraph
- Less suitable for real-time data plotting and updating
Code Comparison
HoloViews:
import holoviews as hv
import numpy as np
xs = np.linspace(0, 10, 200)
curve = hv.Curve((xs, np.sin(xs)))
hv.render(curve)
PyQtGraph:
import pyqtgraph as pg
import numpy as np
plt = pg.plot()
xs = np.linspace(0, 10, 200)
plt.plot(xs, np.sin(xs))
HoloViews offers a more declarative approach, while PyQtGraph provides lower-level control over plot elements. PyQtGraph is generally faster for real-time plotting, while HoloViews excels in creating complex, interactive visualizations with less code.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
PyQtGraph
A pure-Python graphics library for PyQt5/PyQt6/PySide2/PySide6
Copyright 2025 PyQtGraph developers
PyQtGraph is intended for use in mathematics / scientific / engineering applications. Despite being written entirely in python, the library is fast due to its heavy leverage of numpy for number crunching, Qt's GraphicsView framework for 2D display, and OpenGL for 3D display.
Requirements
PyQtGraph has adopted NEP 29.
This project supports:
- All minor versions of Python released 42 months prior to the project, and at minimum the two latest minor versions.
- All minor versions of numpy released in the 24 months prior to the project, and at minimum the last three minor versions.
- Qt5 5.15, and Qt6 6.2+
Currently this means:
Optional added functionalities
Through 3rd party libraries, additional functionality may be added to PyQtGraph, see the table below for a summary.
Library | Added functionality |
---|---|
scipy | |
pyopengl |
|
h5py |
|
colorcet |
|
matplotlib |
|
cupy |
|
numba |
|
jupyter_rfb |
Support
- Report issues on the GitHub issue tracker
- Post questions to
Installation Methods
- From PyPI
- Last released version:
pip install pyqtgraph
- Latest development version:
pip install git+https://github.com/pyqtgraph/pyqtgraph@master
- Last released version:
- From conda
- Last released version:
conda install -c conda-forge pyqtgraph
- Last released version:
- Many linux package repositories have release versions.
Documentation
The official documentation lives at pyqtgraph.readthedocs.io
The easiest way to learn PyQtGraph is to browse through the examples; run python -m pyqtgraph.examples
to launch the examples application.
Used By
Here is a partial listing of some of the applications that make use of PyQtGraph!
- ACQ4
- Antenna Array Analysis
- argos
- Atomize
- EnMAP-Box
- EO Time Series Viewer
- ephyviewer
- Exo-Striker
- GraPhysio
- HussariX
- Joulescope
- MaD GUI
- neurotic
- Bio Silicon Intelligence System
- Orange3
- PatchView
- pyplotter
- PyMeasure
- PySpectra
- rapidtide
- Semi-Supervised Semantic Annotator
- STDF-Viewer
Do you use PyQtGraph in your own project, and want to add it to the list? Submit a pull request to update this listing!
Top Related Projects
matplotlib: plotting with Python
The interactive graphing library for Python :sparkles:
Interactive Data Visualization in the browser, from Python
Statistical data visualization in Python
Main repository for Vispy
With Holoviews, your data visualizes itself.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot