Hi,
The example code below adds a TextItem next to each data point in the plot. At runtime, I manually reduce the height of the window, which results in an updated range for the Y-axis. However, upon further reducing the height of the window, the Y-axis range suddenly starts to rapidly cycle through ever-increasing negative numbers. And this cycling does not stop, until one increases the window height again.
This behavior only occurs when TextItems are present in the plot. Hence, one hypothesis is that the fixed height of the font of the TextItem leads to some cyclic behavior of when setting the range of the axis.
I found some similarities with what was reported by another user here:
The issue was never solved/understood, only side-stepped.
Are there any suggestions on how to prevent this cycling of the Y-axis range when reducing the window height?
Here is the code (pyqtgraph 0.10, pyqt 4.11):
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
app = QtGui.QApplication([])
win = pg.GraphicsWindow()
p1 = pg.PlotItem(y=np.random.normal(size=100))
win.addItem(p1)
curve = p1.curves[0]
for x, y in zip(curve.xData, curve.yData):
marker = pg.TextItem("W")
marker.setPos(x, y)
p1.addItem(marker)
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()