Skip to main content

Monkeypatch for pyqtgraph==0.11.0 resulting in superior OpenGL performance in contrast to more recent 0.11.1 to 0.12.3

Project description

https://img.shields.io/pypi/v/dvg-pyqtgraph-monkeypatch https://img.shields.io/badge/License-MIT-purple.svg

DvG_PyQtGraph_Monkeypatch

Monkeypatch for pyqtgraph==0.11.0 resulting in superior OpenGL performance in contrast to more recent 0.11.1 to 0.12.3

This monkeypatch is safe to import and will only get applied when it detects the correct PyQtGraph version pyqtgraph == 0.11.0. For other versions it will not affect anything at all. Also, when not using OpenGL in experimental mode, nothing changes.

Installation:

pip install dvg-pyqtgraph-monkeypatch

Reason for monkeypatch

This patch is intended for PyQtGraph with OpenGL acceleration enabled as such:

import pyqtgraph as pg
import OpenGL.GL as gl  # pylint: disable=unused-import
pg.setConfigOptions(useOpenGL=True)
pg.setConfigOptions(enableExperimental=True)
pg.setConfigOptions(antialias=True)

Above code will enable OpenGL acceleration within PyQtGraph and adds anti-aliasing to the chart curves. However, from versions 0.11.0 to 0.12.2 it will not draw the linewidth of the curves correctly and they remain at 1 pixel width, regardless of the set linewidth. This patch fixes the linewidth issue.

Why do I fix the PyQtgraph version for this monkeypatch to 0.11.0? Several reasons:

  • 0.11.0 draws the axis tick labels at the borders of the pyqtgraph.PlotWidget nicely, without cutting them off mid-way of the label itself. From 0.11.1 and up the tick labels will be cut off when they are at the border. That can be very confusing when reading the graph.

  • The most recent version at time of writing (0.12.3) actually has fixed the linewidth issue. However, the previous problem on the tick labels still applies.

  • It appears that 0.11.0 has superior plotting performance in frames per second / CPU load in contrast to 0.12.0 and up. This was confirmed and tested in another of my projects https://github.com/Dennis-van-Gils/DvG_Arduino_lock-in_amp. There is a different method used to render the graphs in OpenGL in these more recent PyQtGraph versions.

Usage

You only have to import the module into your Python code after you have imported PyQtGraph. That’s all. The patch will then be applied automatically.

import dvg_monkeypatch_pyqtgraph  # pylint: disable=unused-import

Changelog

2.0.0 (2022-01-20)

  • Turned into a separate PyPi package with proper documentation.

1.0.0 (?)

  • First but unreleased version. Was bundled together with every separate project instead.

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

dvg-pyqtgraph-monkeypatch-2.0.0.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

dvg_pyqtgraph_monkeypatch-2.0.0-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

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