Hi,
I'm using pyqtgraph 0.10.0 in a program used to show and analyse medical time series.
I use a ScatterPlotItem to display identified points. The user can select and delete points individually.
(Here's an example:
https://basket.joachim.cc/2017-03-26_20-33-43.mp4 )
The problem I encounter is the fact that the point data reported by sigClicked does not correspond to the data provided to setData.
I suspect rounding errors occur due to the pixel limitation.
(The concerned code is available here:
https://github.com/jaj42/GraPhysio/blob/master/graphysio/tsplot.py)
Traceback (most recent call last):
File "c:\users\jaj\dev\graphysio\graphysio\tsplot.py", line 93, in keyPressEvent
curve.removeSelection()
File "c:\users\jaj\dev\graphysio\graphysio\tsplot.py", line 193, in removeSelection
return self.removePoints(self.selected)
File "c:\users\jaj\dev\graphysio\graphysio\tsplot.py", line 161, in removePoints
self.starts.drop(idx, inplace=True)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py", line 1907, in drop
new_axis = axis.drop(labels, errors=errors)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\indexes\base.py", line 3262, in drop
labels[mask])
ValueError: labels [1434018138889999872] not contained in axis
Here's a list of points I provided:
Int64Index([1434018135176000000, 1434018135368000000, 1434018135689000000,
1434018135913000000, 1434018136233000000, 1434018136393000000,
1434018136841000000, 1434018136937000000, 1434018137321000000,
1434018137385000000, 1434018137481000000, 1434018137994000000,
1434018138346000000, 1434018138570000000, 1434018138890000000,
1434018139082000000, 1434018139626000000, 1434018139979000000,
1434018140139000000, 1434018140683000000, 1434018141131000000,
1434018141483000000, 1434018141547000000, 1434018141611000000,
1434018141707000000, 1434018142091000000],
dtype='int64', name='datetime_1')
To correct for the problem I use the following pandas method which looks for the closest point in the index, however this is quite inefficient:
index.get_loc(point.pos().x(), method='nearest')
I don't know if there is an easy way to fix this kind of behaviour.
Best regards,
Jona