Skip to main content

What is this project?

This project is about creating an easy to use interface to use matplotlib plots inside QML with the QML-like syntax.

Check out the Documentation!

Installation guide

Just download from pypi:

pip install matplotlib-qml-bindings[pyside2]

or install with a terminal in the repository:

pip install -e .

[!IMPORTANT] If your are installing this package on an Optimizer4D, make sure to leave out the [pyside2] dependencies. Otherwise you will overwrite the local PySide2 installation and break the Analyzer4D software.

Quickstart

If you want to include the bindings in your project to use matplotlib in qml you only need to add these two lines before you initialize your application:

import matplotlib_qml

matplotlib_qml.init()

This will register all plugins for qml.

Example app

In your project directory create two files main.py and main.qml.

main.py:

import sys
from PySide2.QtGui import QGuiApplication
from PySide2.QtQml import QQmlApplicationEngine
from PySide2.QtCore import QUrl

import matplotlib_qml
from pathlib import Path

def main():
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()

    matplotlib_qml.init()

    qml_file = Path(__file__).parent / "main.qml"
    engine.load(QUrl.fromLocalFile(str(qml_file.resolve())))

    if not engine.rootObjects():
        sys.exit(-1)
    
    sys.exit(app.exec_())


if __name__ == "__main__":
    main()

main.qml:

import QtQuick 2.0
import QtQuick.Window 2.0
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.15

import Matplotlib 1.0

Window {
    id: root
    
    width: 1500
    height: 800
    visible: true
    title: "Hello Python World!"
	
	ColumnLayout {
		anchors.fill: parent
		RowLayout {
			Button {
				text: "HOME"
				onClicked: {
					stack.itemAt(tabbar.currentIndex).home()
				}
			}
			Button {
				text: "BACK"
				onClicked: {
					stack.itemAt(tabbar.currentIndex).back()
				}
			}
			Button {
				text: "FORWARD"
				onClicked: {
					stack.itemAt(tabbar.currentIndex).forward()
				}
			}
			Button {
				text: "PAN"
				onClicked: {
					stack.itemAt(tabbar.currentIndex).pan()
				}
			}
			Button {
				text: "ZOOM"
				onClicked: {
					stack.itemAt(tabbar.currentIndex).zoom()
				}
			}
			Text {
				text: "(" + stack.itemAt(tabbar.currentIndex).coordinates[0].toString() + ", " + stack.itemAt(tabbar.currentIndex).coordinates[1].toString() + ")"
			}			
		}
	
	TabBar {
		id: tabbar
		TabButton {
			text: "1"
			width: 100
		}
		TabButton {
			text: "2"
			width: 100
		}
	}
	StackLayout {
		id: stack
		currentIndex: tabbar.currentIndex
		Figure {
			Layout.fillWidth: true
			Layout.fillHeight: true
			Component.onCompleted: init()
			coordinatesRefreshRate: 1000
			Plot {
				Axis {
					Line {
						xData: [10,20,30]
						yData: [10,20,30]
					}
				}
			}
		}
		Figure {
			Layout.fillWidth: true
			Layout.fillHeight: true
			Component.onCompleted: init()
			coordinatesRefreshRate: 1000
			Plot {
				Axis {
					xMin: 0
					xMax: 10
					yMin: 0
					yMax: 10
					autoscale: ""
					ScatterCollection {
						id: collection
						x: [1,2,3,4,5,6,7,8,9]
						y: [1,2,3,4,5,6,7,8,9]
						c: [1,2,3,4,5,6,7,8,9]
						cMap: "gist_rainbow"
						vMin: 0
						vMax: 10
						colorbar: Colorbar {
							orientation: "horizontal"
							location: "bottom"
							}
						}
					}
				}
			}
		}	
	}
}

Release files for matplotlib-qml-bindings 1.0.2

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-qml-bindings 1.0.2
File Size Uploaded
matplotlib_qml_bindings-1.0.2.tar.gz 53.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for matplotlib-qml-bindings 1.0.2
File Interpreter ABI Platform
matplotlib_qml_bindings-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 115.7 kB

Release files / matplotlib_qml_bindings-1.0.2.tar.gz

Download URL matplotlib_qml_bindings-1.0.2.tar.gz
Size 53.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3dce42e366a51bbfaae399636071de6bf734856dfa677e2e9c0ba787f89d66aa
BLAKE2b-256 checksum
How to use checksums
49db0d446e53d825c2c2ca87799792f6814882dd2dcb9b431d9bb6c9dcf96a82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release files / matplotlib_qml_bindings-1.0.2-py3-none-any.whl

Download URL matplotlib_qml_bindings-1.0.2-py3-none-any.whl
Size 62.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b55d62527d545ec931aae84d4625d4d7324a1b8a86b0060692777e0af6feb128
BLAKE2b-256 checksum
How to use checksums
05be2cba893c7a7aee46acfd37eebe42b9e61d2a333cb41b4daaa20979c15802
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0

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