I couldn't get this to work either. However, if you are able to get an event from the plot then to see if you have clicked on a curve you do curve1.curve.mouseShape().contains(e.pos) where e is the event. This returns True or False depending on if the curve is clicked. The trouble is getting the event with the coordinates of the graph and not the viewbox which I am unable to get in your case. For the program I am working on I use an imageitem and plot on top of that, but I have different data than you.
Hope this helps On Monday, June 19, 2017 at 7:46:40 PM UTC-6, wot wrote: > > I want to be able to select a line on a line graph. I was using plot but > it doesn't appear to work so I tried PlotCurveItem, which does work. I > guess I am missing something but I was expecting plot to work like > PlotCurveItem for the line graph. Plotting points works as expected using > plot. > > import pyqtgraph as pg > > from PyQt4 import QtGui > > import numpy as np > > import sys > > > > > def main(): > > def clicked1(curve, points): > > > print(curve) > > print(points) > > def clicked2(points): > > print(points) > > > > app = QtGui.QApplication(sys.argv) > > widg = QtGui.QWidget() > > widg.move(100, 100) > > > > pgWidg = pg.GraphicsLayoutWidget() > > pgWidg.resize(750, 250) > > > > graph = pgWidg.addPlot(row=1, col=1) > > curve1 = graph.plot(y=np.sin(np.linspace(0, 20, 1000)), symbol='o', > clickable=True) > > curve2 = graph.plot(y=np.sin(np.linspace(1, 21, 1000)), pen='r', > clickable=True) > > curve3 = pg.PlotCurveItem(y=np.sin(np.linspace(2, 22, 1000)), pen='b', > clickable=True) > > graph.addItem(curve3) > > > > curve1.sigPointsClicked.connect(clicked1) > > curve2.sigPointsClicked.connect(clicked1) > > curve2.sigClicked.connect(clicked2) > > curve3.sigClicked.connect(clicked2) > > > > grid = QtGui.QGridLayout() > > grid.addWidget(pgWidg, 0,0) > > widg.setLayout(grid) > > widg.show() > > sys.exit(app.exec_()) > > > > > if __name__ == '__main__': > > main() > > > -- 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/c7522f54-50ef-4c07-af23-c3a41bbec429%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
