Skip to main content

matplotlib_backend_qtquick

This package implements a QtQuick backend for matplotlib. It started from maplotlib_qtquick_playground, written by Frédéric Collonval, but it has been updated to work with the current version (3.2.1) of matplotlib.

Usage

In order to use matplotlib plots with QtQuick, do the following:

  1. In your main.py, use QtQml.qmlRegisterType to register FigureCanvasQtQuickAgg under whichever name you want to use.
  2. In your QML files, instantiate an object with the QML type defined above. Its objectName property specifies the name of the object that can be found in the QML engine. It can be retrieved in python with win.findChild(QtCore.QObject, "spectFigure"), for example, where "spectFigure" is the objectName in this case.
  3. One can then pass this object as needed. This is the FigureCanvasQtQuickAgg object. The figure can be found in its figure property.

For interactive plots, if you want to use the toolbar, to the Bridge class add slots like:

    @QtCore.Slot()
    def zoom(self, *args):
        """activate zoom tool."""
        self.toolbar.zoom(*args)

One can also connect to Matplotlib events:

       self._figure.canvas.mpl_connect('button_press_event', self.onClick)
       self._figure.canvas.mpl_connect('scroll_event', self.onScroll)

and provide the callbacks, for example:

    def onClick(self, event):
        """
        Handle mouse clicks in the three slices:
        set the slice to what is clicked.
        """
        if event.button == MouseButton.LEFT:
            if event.inaxes == self.axeses[0]:
                self.x = self._findBin(self.xAxis, event.xdata)
                self.y = self._findBin(self.yAxis, event.ydata)
                self.setSlice()
            elif event.inaxes == self.axeses[1]:
                self.x = self._findBin(self.xAxis, event.xdata)
                self.z = self._findBin(self.zAxis, event.ydata)
                self.setSlice()
            elif event.inaxes == self.axeses[2]:
                self.y = self._findBin(self.yAxis, event.xdata)
                self.z = self._findBin(self.zAxis, event.ydata)
                self.setSlice()

    def onScroll(self, event):
        """
        Handle mouse scroll in the three slices
        - scroll the independent variable
        """
        if event.inaxes == self.axeses[0]:
            self.z += int(event.step)
            self.setSlice()
        elif event.inaxes == self.axeses[1]:
            self.y += int(event.step)
            self.setSlice()
        elif event.inaxes == self.axeses[2]:
            self.x += int(event.step)
            self.setSlice()

Please let me know if you have any suggestions or better ways I should do this.

Examples

The example in the examples directory gives a simple example of how to use this backend, including interactions.

Metadata

Release files for matplotlib-backend-qtquick 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matplotlib-backend-qtquick 0.0.8
File Size Uploaded
matplotlib_backend_qtquick-0.0.8.tar.gz 14.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for matplotlib-backend-qtquick 0.0.8
File Interpreter ABI Platform
matplotlib_backend_qtquick-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / matplotlib_backend_qtquick-0.0.8.tar.gz

Download URL matplotlib_backend_qtquick-0.0.8.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
40373f7e06fd7773a4df44da40cd14a0e7f3e59291446348c8788144f1c80436
BLAKE2b-256 checksum
How to use checksums
2cb5f0a3d793485abdba4ee57a99efc187eb8f4fece07811c67ada2913bdb87e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / matplotlib_backend_qtquick-0.0.8-py3-none-any.whl

Download URL matplotlib_backend_qtquick-0.0.8-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a3a6d682e2d15d24b9a93ab6b273fba26d7441f699c6f6bd6213f157768b9e9
BLAKE2b-256 checksum
How to use checksums
2e976cb758d90bd1c34a85002684f2da5c51e527b5646b7b8fd577e7d4e31ebb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page