Discussion:
How to get the data coordinate by clicking?
Till Stensitzki
2011-06-22 10:46:30 UTC
Permalink
Hello,

i want to let the user choose a x coordinate with a click in the plot.
To do that, i tried the following (subclassing CurvePlot):

class Wavelength_plot(CurvePlot):
def __init__(self, *args):
super(Wavelength_plot,self).__init__(*args)

def mousePressEvent(self,event):
curve=self.get_items()[1]
new_ch=curve.hit_test(event.pos())
print new_ch
controller.set_ch(new_ch[1])
print controller.ch

But this dosen't work correctly (chooses the wrong x, maybe the
position is given in the wrong coordinate basis?

greetings,
Till

Loading...