Invalid points not causing line drawing to stop

57 views
Skip to first unread message

AB

unread,
Sep 30, 2022, 10:27:06 AM9/30/22
to pyqtgraph
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?

Ognyan Moore

unread,
Sep 30, 2022, 11:02:50 AM9/30/22
to pyqt...@googlegroups.com
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.

--
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 pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/559c2c62-8372-471f-b36c-77e314368006n%40googlegroups.com.

AB

unread,
Sep 30, 2022, 11:09:38 AM9/30/22
to pyqtgraph
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.

AB

unread,
Sep 30, 2022, 11:11:44 AM9/30/22
to pyqtgraph
np.nan also misbehaves.

AB

unread,
Sep 30, 2022, 11:27:30 AM9/30/22
to pyqtgraph
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.
read_position_qt.py

Patrick

unread,
Oct 1, 2022, 1:36:07 AM10/1/22
to pyqtgraph
Can reproduce with latest version of pyqtgraph. Some bug with detection of nan/infs, but only on subsequent updates (note the first draw renders correctly). Adding an explicit connect="finite" to the setData calls works as expected.

AB

unread,
Oct 3, 2022, 4:55:25 AM10/3/22
to pyqtgraph
Thanks for the feedback - adding the connect parameter does appear to make it behave properly.

Playing with it again on my full application (without the additional parameter), it looks like it happens more frequently when the (Y) axis is manually scaled.

Should I open this as a Github issue?

Ognyan Moore

unread,
Oct 3, 2022, 9:19:54 AM10/3/22
to pyqt...@googlegroups.com
I would recommend opening a GitHub issue. I would highly recommend putting an example there and if you can catch a gif/video of the output that would be gear too (but not necessary).


AB

unread,
Oct 3, 2022, 10:00:55 AM10/3/22
to pyqtgraph
Reply all
Reply to author
Forward
0 new messages