Big Data, Data Analytics, IOT, Data Lake - Submit Your Guest Post
cloud innovation

An overview of the PyQtGraph library in python for interactive graph visualization

PyQtGraph is a graphics library written in python. GUI elements are implemented in PyQt4 / PySide and numpy .

It is intended for use in mathematical, scientific, and engineering applications. Despite the fact that this library is completely written in python, it is very fast due to the use of numpy for working with data and GraphicsView from Qt for rendering items. PyQtGraph is licensed under the MIT open-source license.

Basic functionality

  • Conventional 2D plots in interactive mode:
    • Line and scatter charts.
    • Data can be shifted / scaled with the mouse.
    • Adding new data to the chart in real time.
  • Displaying individual areas of images with different parameters: 
    • Support for a large number of source data types (int or float, any kind of depth map, RGB, RGBA).
    • Functions for slicing multidimensional data from different angles (great for tomographic images).
    • Fast update for video streaming or handling real-time graph interactions.
  • 3D graphics (requires Python-OpenGL libraries to be installed):
    • Displaying a large amount of data.
    • Visualization of 3D surfaces and point clouds.
    • Rendering a mesh with an isosurface.
    • Live view with rotation / scaling with the mouse.
    • Basic visualization of the object hierarchy for an easier way to manipulate objects.
  • Highlighting / marking regions of interest on data:
    • Interactive labels in the vertical / horizontal axes and rectangular regions on the chart.
    • Widgets for highlighting data slices and automatically scaling to that slice.
  • Easy generation of new charts:
    • 2D charts use Qt’s GraphicsView, which are feature rich and reliable.
    • 3D graphics use OpenGL.
    • All graphs use a scene graph to manipulate objects, so new objects are very easy to create.
  • Library of widgets and modules are useful for scientific / engineering applications:
    • Flowchart widget for interactive prototyping. The interface is similar to LabView (nodes are connected through lines).
  • Parameters widget for displaying / editing parameter hierarchies (similar to those used by most graphical GUI applications).
  • An interactive python console with the ability to capture errors. Well suited for debugging / introspection of code when analyzing user interaction with the UI.
  • The dock system allows the user to reorganize the GUI components as they wish. Similar to the Qt dock system, but slightly more flexible and programmable.
  • Editor for editing color gradients.
  • SpinBox with SI unit display and logarithmic step.

Advantages and Disadvantages Compared to Competitors

  • Matplotlib  is a more or less standard python plotting library. If you’re starting a new project and don’t need any of the features that pyqtgraph provides, you should start with matplotlib. It is much more mature, has a huge user community and makes a very good impression in terms of rendering quality.
  • VisPy is a new OpenGL-based 2D / 3D rendering library developed in collaboration with the authors of PyQtGraph, VisVis, Galry and Glumpy. It is currently in an early stage of development and has a narrower scope than PyQtGraph – it focuses on rendering without the GUI toolkit provided by PyQtGraph. In the long term, we hope that VisPy should replace Qt as the rendering engine for 2D graphics and completely replace the opengl 3D pyqtgraph system. More about VisPy here .
  • PyQwt has a very large feature set and is fast enough for real-time work. Its main drawback is that it is not currently supported and may not perform well on various platforms. Hopefully it finds new developers in the future, but until then it is best to avoid PyQwt (the original PyQwt developer currently recommends using PyQtGraph). Like matplotlib, PyQwt lacks some of the more advanced pyqtgraph features.
  • Chaco is a very interesting project. Good graphics, good speed and actively developing. However, like PyQwt, Chaco can be tricky to install on various platforms and lacks some of the more complex features introduced in PyQtGraph (although pyqtgraph certainly lacks many of Chaco’s features).
  • GuiQwt is an interesting project with functions similar to pyqtgraph. It is currently based on PyQwt and therefore has some of its shortcomings, although they are expected to be fixed in the future.

Reasons why you might want to use PyQtGraph

  1. Speed . If you are doing anything that requires fast plots, video, or real-time interactivity to update, matplotlib is not the best choice. This is perhaps the biggest weakness of matplotlib.
  2. Portability / ease of installation . PyQtGraph is a pure-python package, which means it works on almost every platform numpy and PyQt supports without compiling. If you need portability of  your application between platforms, it can make your life a lot easier.
  3. PyQtGraph is much more than just a graphics library . It aims to cover many aspects of scientific and engineering application development with more advanced features such as ImageView and ScatterPlotWidget analysis tools, ROI-based data slicing, parameter trees, flowcharts, multiprocessing and much more.

Dataflickr Team

Your Header Sidebar area is currently empty. Hurry up and add some widgets.