-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Short description
The DateTime Axis has rendering issues with zoomed in past the 5ish minute level.
Either the rendered plot is missing data or during panning the axis and plot lose sync.
I have attempted to use the optimization options such as clipToView, however they do not seem to provide benefit.
There is a thread outlining zoom issues from floating point rounding. Maybe this is a similar issue?
The DateTime axis accepts seconds since epoch as its time units, is it possible to use time_ns() to get nanoseconds since epoch or milliseconds since epoch?
Code to reproduce
import sys
import time
import os
import numpy as np
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui, QtWidgets, QT_LIB, loadUiType
def make_data ():
now = time.time()
npoints = int(1e5)
seconds_in_day = 86400
x = np.linspace(now - 6*30*seconds_in_day, now, npoints)
y = np.random.rand(npoints)
return x, y
if QT_LIB.startswith('PyQt'):
wrapinstance = pg.Qt.sip.wrapinstance
else:
wrapinstance = pg.Qt.shiboken.wrapInstance
# ----------
# set options
pg.setConfigOption('background', 'w')
pg.setConfigOption('foreground', 'k')
pg.setConfigOption('useOpenGL', True)
pg.setConfigOption('enableExperimental', True)
# don't limit frame rate to vsync
sfmt = QtGui.QSurfaceFormat()
sfmt.setSwapInterval(0)
QtGui.QSurfaceFormat.setDefaultFormat(sfmt)
# ----------
# setup ui
app = pg.mkQApp("Plot Speed Test")
default_pen = pg.mkPen(width=2)
pw = pg.PlotWidget()
splitter = QtWidgets.QSplitter()
splitter.addWidget(pw)
splitter.show()
pw.setWindowTitle('zoom test')
pw.setLabel('bottom', 'Index', units='B')
# ----------------
# setup plot
lcurve = pw.plot(
*make_data(),
connect="pairs",
pen=default_pen
)
pw.addItem(lcurve)
# ----------------
# set plot options
pw.setMouseEnabled(x=True, y=False)
pw.setYRange(0, 1, padding=0.5, update=False)
pw.setAxisItems({'bottom': pg.DateAxisItem()})
pw.setLimits(xMin=-1)
if __name__ == '__main__':
pg.exec()Expected behavior
Zoom into July 1st, ~23:55. Zoom until the axis ticks reach a 5 minute interval.
While panning, the plot should stay in sync with the axis.
Keep zooming in and there should not be rendering artifacts.
Real behavior
Zoom into July 1st, ~23:55. Zoom until the axis ticks reach a 5 minute interval.
The plot begins to lag and the axis loses sync with the plot.
You can also see the plot through the vertical axis on the left
Keep zooming in and you can see rendering artifacts popping up.
Tested environment(s)
- PyQtGraph version: 0.12.3
- Qt Python binding: PySide6 6.2.0 Qt 6.2.0
- Python version: 3.9.7
- NumPy version: 1.21.2
- Operating system: Windows 10
- Installation method: pip