Matplotlib with Qt5 + PySide2 backend

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
ian.rees
Posts: 696
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Matplotlib with Qt5 + PySide2 backend

Post by ian.rees »

Just wanted to share this in case it's useful here. Matplotlib has support for Qt5 with PySide2 as a backend, but as far as I can tell, it's currently only in the git source from some time after 2.0.0 - currently the latest release. It's pretty easy to install the latest matplotlib source:

Code: Select all

$git clone https://github.com/matplotlib/matplotlib.git
$cd matplotlib
$python setup.py develop
(the "develop" target is handy - it is much like "install", but makes symlinks to the build directory instead of copying files)

Then, Python scripts can use eg:

Code: Select all

import matplotlib
matplotlib.use('Qt5Agg')
matplotlib.rcParams['backend.qt5']='PySide2'
Post Reply