NOTE These Backends are not (auto) documented here, to avoid adding a dependency to building the docs.
There are currently 2 actively supported Qt versions, Qt5 and Qt6, and two
supported Python bindings per version -- PyQt5 and PySide2 for Qt5 and PyQt6 and PySide6 for Qt6 . Matplotlib's
qtagg and qtcairo backends (
matplotlib.backend.backend_qtcairo) support all these bindings, with common
parts factored out in the
At runtime, these backends select the actual binding used as follows:
If a binding's
QtCoresubpackage is already imported, that binding is selected (the order for the check is
Otherwise, the first available backend in the order
In the past, Matplotlib used to have separate backends for each version of Qt
matplotlib.backends.backend_qt5agg). This scheme was dropped when
support for Qt6 was added. For back-compatibility, qt5agg/
backend_qt5cairo remain available; selecting one of these
backends forces the use of a Qt5 binding. Their use is discouraged and
backend_qtcairo should be preferred instead. However,
these modules will not be deprecated until we drop support for Qt5.
While both PyQt
and Qt for Python (aka PySide) closely mirror the underlying C++ API they are
wrapping, they are not drop-in replacements for each other . To account
for this, Matplotlib has an internal API compatibility layer in
matplotlib.backends.qt_compat which covers our needs. Despite being a public
module, we do not consider this to be a stable user-facing API and it may
change without warning .