Skip to main content

QCustomPlot is a Qt widget for plotting and data visualization

Project description

QCustomPlot for PyQt5 and PyQt6

Design goals

This is Python bindings for QCustomPlot - Qt C++ library for plotting and data visualization. This binding can be complied for use with PyQ5 or PyQt6. There are myriads of Python charting libraries out there, and each may even have its reason to exist. QCustomPlot has the following goals:

  • Performance. QCustomPlot is written in modern C++ with the excellent Qt library for superior performance over alternative libraries.

  • Flexibility. QCustomPlot is one of the most customisable libraries available, with a wide range of supported graph types and full control over how the graph is rendered.

Installing

Linux

You can find compiled packages for many Linux distributions at OBS.

Windows

Install the package via our favourite package manager:

$ pip install QCustomPlot_PyQt5

or

$ pip install QCustomPlot_PyQt6

Getting started

Now let's take a look at some code:

import sys
import math
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPen, QBrush, QColor
from PyQt5.QtWidgets import QApplication, QMainWindow
from QCustomPlot_PyQt5 import *


app = QApplication(sys.argv)
window = QMainWindow()
window.resize(800, 600)

customPlot = QCustomPlot()
window.setCentralWidget(customPlot)

graph0 = customPlot.addGraph()
graph0.setPen(QPen(Qt.blue))
graph0.setBrush(QBrush(QColor(0, 0, 255, 20)))

graph1 = customPlot.addGraph()
graph1.setPen(QPen(Qt.red))

x, y0, y1 = [], [], []
for i in range (251):
    x.append(i)
    y0.append(math.exp(-i/150.0)*math.cos(i/10.0))  # exponentially decaying cosine
    y1.append(math.exp(-i/150.0))                   # exponential envelope

graph0.setData(x, y0)
graph1.setData(x, y1)

customPlot.rescaleAxes()
customPlot.setInteraction(QCP.iRangeDrag)
customPlot.setInteraction(QCP.iRangeZoom)
customPlot.setInteraction(QCP.iSelectPlottables)

window.show()
sys.exit(app.exec_())

That's all!

Some important things:

  • QCustomPlot is a QWidget type that can be used the same way as any other widget, added to layouts, etc. However, you can nest multiple graphs in a single QCustomPlot using layouts (see the Advanced Axes demo).

Examples

Beside the examples below, you may want to check the documentation.

Supported compilers

The following compilers are known to work:

  • MSVC 140, 141
  • GCC 4.8
  • Clang 3.4

I would be happy to learn about other compilers/versions.

License

This code is licensed under the MIT License:

Copyright © 2017-2023 Dmitry Voronin, Christopher Gilbert and Sergey Salnikov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Part of the code is licensed under the GPL Version 3 License.


This project contains the QCustomPlot library from Emanuel Eichhammer which is licensed under the GPL Version 3 License. Copyright © 2011-2022 Emanuel Eichhammer bjoern@hoehrmann.de

Contact

If you have questions regarding the library, I would like to invite you to open an issue at Github. Please describe your request, problem, or question as detailed as possible, and also mention the version of the library you are using as well as the version of your compiler and operating system. Opening an issue at GitHub allows other users and contributors to this library to collaborate.

Thanks

I deeply appreciate the help of the following people.

  • DerManu is the official author and maintainer of the excellent QCustomPlot library.
  • dimv36 is the original author of the Python bindings for QCustomPlot 1.0.0, upon which this project is based.
  • cowo78 and cjgdev added support for the QCustomPlot 2.0.0 API.

Thanks a lot for helping out! Please let me know if I forgot someone.

Used third-party tools

This library is built, tested, documented, and whatnot using third-party tools and services. Thanks a lot!

  • SIP to generate the Python bindings.

Projects using

  • GPX Viewer --- an application for viewing GPX files as a list of points and tracks.

If you are using QCustomPlot-PyQt5 in a project and would like to share with the community, please let me know, or even better, raise a pull request.

Building from sources

Linux

Apt users (Debian, Ubuntu, etc) may follow the instructions below, users of other distributions may adapt the steps below for your own package manager. Qt5 or Qt6 can be used as a dependency.

# Fetch the necessary development tools and libraries
$ apt-get install build-essential python3-pyqt5 pyqt5-dev-tools qttools5-dev-tools

# Clone the repository and submodules
$ git clone --recursive https://github.com/salsergey/QCustomPlot-PyQt.git && cd QCustomPlot-PyQt

# Build
$ sip-build --qmake _path_to_qmake5_or_qmake6_

# Zzz..

# Install
$ sip-install --qmake _path_to_qmake5_or_qmake6_

Windows

Windows users should install Qt tools, appropriate version of VC compiler, Python, PyQt5 and SIP. You may need to build SIP from sources to ensure you have all files necessary for building other software. Then follow the instructions below to build the library, otherwise you will need to adapt the steps for your own environment.

  • Download QCustomPlot-PyQt sources from Github. You can use git or download an archive.
  • Launch Qt console and follow instructions there. It will ensure that you have all necessary tools in your PATH variable. Also be sure that python.exe binary is in your PATH.
  • Then follow these instructions:
# Go to QCustomPlot folder
cd <<PATH_TO QCustomPlot-PyQt>>

# Download submodules if you use git
git submodules update --init

# Build
sip-build --qmake _path_to_qmake5_or_qmake6_

# Zzz..

# Install
sip-install --qmake _path_to_qmake5_or_qmake6_

macOS

Users of macOS using homebrew may follow the instructions below to fetch the required packages to build the library, or simply adapt to your own environment.

# First ensure Xcode is installed, as homebrew depends on it
$ xcode-select --install

# Fetch the necessary development tools and libraries
$ brew install pyqt@5

# Clone the repository and submodules
$ git clone --recursive https://github.com/salsergey/QCustomPlot-PyQt.git && cd QCustomPlot-PyQt

# Build
$ CFLAGS='-std=c++11 -stdlib=libc++' CXXFLAGS='-std=c++11 -stdlib=libc++' sip-build --qmake _path_to_qmake5_or_qmake6_

# Zzz..

# Install
$ sip-install --qmake _path_to_qmake5_or_qmake6_

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

QCustomPlot_PyQt5-2.1.1.2.tar.gz (487.9 kB view details)

Uploaded Source

Built Distributions

QCustomPlot_PyQt5-2.1.1.2-cp312-none-win_amd64.whl (771.6 kB view details)

Uploaded CPython 3.12 Windows x86-64

QCustomPlot_PyQt5-2.1.1.2-cp312-cp312-manylinux_2_17_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

QCustomPlot_PyQt5-2.1.1.2-cp311-none-win_amd64.whl (773.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

QCustomPlot_PyQt5-2.1.1.2-cp311-cp311-manylinux_2_17_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

QCustomPlot_PyQt5-2.1.1.2-cp310-none-win_amd64.whl (772.9 kB view details)

Uploaded CPython 3.10 Windows x86-64

QCustomPlot_PyQt5-2.1.1.2-cp310-cp310-manylinux_2_17_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

File details

Details for the file QCustomPlot_PyQt5-2.1.1.2.tar.gz.

File metadata

  • Download URL: QCustomPlot_PyQt5-2.1.1.2.tar.gz
  • Upload date:
  • Size: 487.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for QCustomPlot_PyQt5-2.1.1.2.tar.gz
Algorithm Hash digest
SHA256 ff797c0d5793b188c1208530cda1009213dcf52ae10dcbe63208cec313f32299
MD5 eed26769f01c6dfaf3e511c3f23cf788
BLAKE2b-256 5f2f700739dc255dc0d90b6cb2e959a312b3cf0775e808a5bc6498021739c229

See more details on using hashes here.

File details

Details for the file QCustomPlot_PyQt5-2.1.1.2-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for QCustomPlot_PyQt5-2.1.1.2-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 922b81c30a37d7e2f07dda094c4087c397940bc45237845fe4271b157f1725a6
MD5 88eec24da0fbd06774c3e33d85f1a797
BLAKE2b-256 589718f71e2b141da9bb623fd54897af6e8e68768a542573805e37dbd7d5ef1c

See more details on using hashes here.

File details

Details for the file QCustomPlot_PyQt5-2.1.1.2-cp312-cp312-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for QCustomPlot_PyQt5-2.1.1.2-cp312-cp312-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ce2675e2b151171687ae532965878a422510ec9ac36c7be60d19eff302663b1d
MD5 90f611f5d7d7afbbc28eae270d9a5d0d
BLAKE2b-256 3ea5ffb09be0bf8cf4971b26fee7bacf5336bc6ff637293c72049d72bf52b4f6

See more details on using hashes here.

File details

Details for the file QCustomPlot_PyQt5-2.1.1.2-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for QCustomPlot_PyQt5-2.1.1.2-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 9b0e5027c6b7aff3b75cb8f77397f0afa76d747abb089399216e4502ca8cc21c
MD5 112bc58de3edff053aba1ec839fe1132
BLAKE2b-256 bc0d9305ed745f395af91340d631c9f6588a764224aa10748e6fc61d7243f657

See more details on using hashes here.

File details

Details for the file QCustomPlot_PyQt5-2.1.1.2-cp311-cp311-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for QCustomPlot_PyQt5-2.1.1.2-cp311-cp311-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 1b2d478733fb2cb154f59ef3e21ff80bd00163cd6741fe9419df473d2e547637
MD5 55ca695d26336f8ae7f646702bfdb487
BLAKE2b-256 994e6238987c9127c70386f9ec7c7db341fed274d4b6cf6dd7f54e4469060673

See more details on using hashes here.

File details

Details for the file QCustomPlot_PyQt5-2.1.1.2-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for QCustomPlot_PyQt5-2.1.1.2-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 d719876aa8c0b8a56a206697dd1bcbcd6aaef3fcf09571346b02db0ba6ea80b7
MD5 9c5a75291b546205b1c978eb4b20d594
BLAKE2b-256 4a01135e4784f084accbb9b4f4c3588ac5cd66706449f28b0f64ac7a9551a3cc

See more details on using hashes here.

File details

Details for the file QCustomPlot_PyQt5-2.1.1.2-cp310-cp310-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for QCustomPlot_PyQt5-2.1.1.2-cp310-cp310-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 baaba9f70c33dea1989c89f15d659b98b0b3d6bee67941aab02beb5dcc90de71
MD5 a8bd3736fed0a0713430a2e1bb8d868a
BLAKE2b-256 007fa4f903bb2ad64dc5c394fbb78ad36ed42731e1da4a3818c308c5e5eb21b2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page