VisPy
VisPy is a high-performance interactive 2D/3D data visualization library in Python. It leverages the computational power of modern Graphics Processing Units (GPUs) through OpenGL to display very large datasets and facilitate real-time data visualization. Currently at version 0.16.1, the library is under active development with a roadmap towards a 1.0 release, focusing on stability, performance, and higher-level interfaces for ease of use.
Warnings
- gotcha VisPy requires at least one GUI toolkit backend (e.g., PyQt5, PySide2, GLFW) and an up-to-date GPU driver with OpenGL 2.1+ support to function. Without these, applications may fail to run or display correctly.
- gotcha Performance can degrade significantly when creating many individual `Visual` objects. VisPy internally treats each visual as a separate OpenGL program, leading to overhead.
- gotcha OpenGL operations, including calls to `self.update()` on VisPy Canvas or Visual objects, must be performed on the main/GUI thread. While data updates can occur in secondary threads, the final redraw command must originate from the main thread.
- breaking VisPy is pre-1.0 and undergoing heavy development, meaning its internal API and behavior, especially for visuals, can change between minor versions. This has historically caused incompatibilities for applications relying on specific internal implementations.
- deprecated The low-level `gloo` interface and GLIR (Graphics Library Intermediate Representation) are likely to be deprecated in future versions as development shifts focus towards higher-level interfaces.
Install
-
pip install vispy
Imports
- app, scene
from vispy import app, scene
- SceneCanvas
from vispy.scene import SceneCanvas
- visuals
from vispy.scene import visuals
- Color
from vispy.color import Color
- gloo
from vispy import gloo
Quickstart
import sys
import numpy as np
from vispy import scene, app
from vispy.color import Color
# Create a canvas
canvas = scene.SceneCanvas(keys='interactive', size=(800, 600), show=True)
canvas.title = "VisPy Cube"
# Create a viewbox
view = canvas.central_widget.add_view()
view.camera = 'turntable' # For 3D interaction
# Create a cube visual and add to the view
cube_mesh = scene.visuals.Cube()
view.add(cube_mesh)
# Set background color
view.bgcolor = Color('black')
# Start the event loop
if __name__ == '__main__':
print("VisPy window opened. Close it to exit.")
app.run()