OK, I've hacked down the application to a small-ish file (attached). There
are two graphs, side-by-side. They both have some data with an invalid
section and it is consistently being drawn across until I change the zoom
level - it then reappears on the next graph update.
On Friday, 30 September 2022 at 16:11:44 UTC+1 AB wrote:
> np.nan also misbehaves.
>
> On Friday, 30 September 2022 at 16:09:38 UTC+1 AB wrote:
>
>> Since posting earlier, I've tried float("nan"), float("inf") and np.inf
>> and they all behave exactly the same. I'll see if I can cut my
>> application's code down to something I can share.
>>
>> I did manage to "stop" the graph while the glitch was displayed (and by
>> "stop" I mean that the application was running but I stopped making further
>> calls to setData). Before zooming the graph I used the context-menu to
>> export data to CSV and I could clearly see that there was a period exported
>> as "inf" where the line was being displayed.
>>
>> On Friday, 30 September 2022 at 16:02:50 UTC+1 [email protected] wrote:
>>
>>> Hmm, that certainly should not be happening, not sure quite why things
>>> would be going like that. If you can, I would try slowing down the update
>>> rate of the plot, to easily catch one of those instances and post some code
>>> here if you can for us to try and replicate.
>>>
>>> Another suggestion would be to set the invalid points to numpy.nan
>>> instead of float("inf") and see if that gets better behavior; I think that
>>> was the value we were originally looking for.
>>>
>>> On Fri, Sep 30, 2022 at 7:27 AM AB <[email protected]> wrote:
>>>
>>>> I am trying to display some data in a line graph - there are 1024
>>>> points, updating ~40 times/second. Some of the points are invalid (set to
>>>> float("inf") ) and are supposed to cause a break in the line if I
>>>> understand the default behaviour of the "connect" parameter correctly.
>>>> However, I am periodically seeing that there is a straight line joining
>>>> the
>>>> valid points either side of the invalid period.
>>>>
>>>> I can stop updating the graph and catch this happening - as soon as I
>>>> use the mouse zoom functionality to change the scale of the graph in this
>>>> state the erroneous line vanishes, and the graph is drawn with breaks in
>>>> the line as I expect that it should.
>>>>
>>>> Can anyone suggest why the erroneous lines are appearing, and how I can
>>>> ensure they don't appear?
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "pyqtgraph" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/pyqtgraph/559c2c62-8372-471f-b36c-77e314368006n%40googlegroups.com
>>>>
>>>> <https://groups.google.com/d/msgid/pyqtgraph/559c2c62-8372-471f-b36c-77e314368006n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/8125afaa-e714-47a5-bb1d-5ba5bcd362f1n%40googlegroups.com.
import sys
from PySide6 import QtWidgets, QtCore
import pyqtgraph as pg
import logging
class SENSORDemo(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
# central widget
central_widget = QtWidgets.QWidget()
# create widgets
self.start_button = QtWidgets.QPushButton("Start")
self.update_timer = QtCore.QTimer()
plot_box = QtWidgets.QGroupBox()
plot_box_layout = QtWidgets.QGridLayout()
self.halt_graph_update = QtWidgets.QCheckBox("Update graphs")
self.halt_graph_update.setChecked(True)
pg.setConfigOption("background", "w")
pg.setConfigOption("foreground", "k")
pos_plot_widget = pg.GraphicsLayoutWidget()
vel_plot_widget = pg.GraphicsLayoutWidget()
pos_plot = pos_plot_widget.addPlot(title="P")
vel_plot = vel_plot_widget.addPlot(title="V")
# pos_plot = self.plot.addPlot(row=0, col=0)
# vel_plot = self.plot.addPlot(row=0, col=1)
pos_plot.getViewBox().setMouseMode(pg.ViewBox.RectMode)
pos_plot.getViewBox().setMouseEnabled(x=False, y=True)
pos_plot.getViewBox().setLimits(xMin=0, xMax=1024, minXRange=1024)
pos_plot.getAxis("left").setStyle(
autoExpandTextSpace=True, autoReduceTextSpace=False
)
vel_plot.getViewBox().setMouseMode(pg.ViewBox.RectMode)
vel_plot.getViewBox().setMouseEnabled(x=False, y=True)
vel_plot.getViewBox().setLimits(xMin=0, xMax=1024, minXRange=1024)
vel_plot.getAxis("left").setStyle(
autoExpandTextSpace=True, autoReduceTextSpace=False
)
self.pos_plot_line = pos_plot.plot()
self.vel_plot_line = vel_plot.plot()
plot_box_layout.addWidget(
self.halt_graph_update, 0, 0, 1, 2, QtCore.Qt.AlignCenter
)
plot_box_layout.addWidget(pos_plot_widget, 2, 0, 1, 1)
plot_box_layout.addWidget(vel_plot_widget, 2, 1, 1, 1)
plot_box.setLayout(plot_box_layout)
# layout widgets
central_layout = QtWidgets.QGridLayout()
central_layout.addWidget(plot_box, 4, 0, 1, 2)
central_widget.setLayout(central_layout)
self.setCentralWidget(central_widget)
# connect signals/slots
self.update_timer.timeout.connect(self.update_position)
self.update_timer.start(1000)
@QtCore.Slot()
def update_position(self):
if self.halt_graph_update.isChecked():
samples = [x % 10 if x < 100 or x > 150 else float("nan") for x in range(1024)]
self.pos_plot_line.setData(
[x for x in samples],
pen=(0, 0, 255),
)
self.vel_plot_line.setData(
[x for x in samples],
pen=(0, 0, 255),
)
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
app = QtWidgets.QApplication(sys.argv)
app.setApplicationName("Read Sensor")
sensordemo = SENSORDemo()
sensordemo.resize(800, 600)
sensordemo.show()
sys.exit(app.exec())