How to get the coordinates (picker)

Hi,

I'm trying to write a pyqt4 application including pylab plotting
capabilities.
Up to now, it looks like this (see in attachment).

The picker works fine (I get the msg) *but* I also would like to get the
(x,y) coordinates and the the corresponding value A[x,y].
Could someone tell me what I should do in on_pick with this "event" to
get these data??

Xavier

test2PyQt.py (2.35 KB)

Hi Xavier,

I'm trying to write a pyqt4 application including pylab plotting
capabilities.
Up to now, it looks like this (see in attachment).

The picker works fine (I get the msg) *but* I also would like to get
the (x,y) coordinates and the the corresponding value A[x,y].
Could someone tell me what I should do in on_pick with this "event"
to get these data??

Xavier

This works for me:

     def on_pick(self, event):
         tt = event.artist.get_axes()
         mouseevent = event.mouseevent
         msg = "X is: " + str(mouseevent.xdata) + "\nY is: " + str(mouseevent.ydata)
         QMessageBox.information(self, "Click!", msg)

I got some good tips on how to do this from examples/event_handling/pick_event_demo.py

···

--
Christopher Brown, Ph.D.
Department of Speech and Hearing Science
Arizona State University

Christopher Brown wrote:

Hi Xavier,

> I'm trying to write a pyqt4 application including pylab plotting
> capabilities.
> Up to now, it looks like this (see in attachment).
>
> The picker works fine (I get the msg) *but* I also would like to get
> the (x,y) coordinates and the the corresponding value A[x,y].
> Could someone tell me what I should do in on_pick with this "event"
> to get these data??
>
> Xavier

This works for me:

    def on_pick(self, event):
        tt = event.artist.get_axes()
        mouseevent = event.mouseevent
        msg = "X is: " + str(mouseevent.xdata) + "\nY is: " +
str(mouseevent.ydata)
        QMessageBox.information(self, "Click!", msg)

I got some good tips on how to do this from
examples/event_handling/pick_event_demo.py

Thanks!! It works just fine :). IDL is dead. Qt4 python and
numpy/scipy/numpy are great tools.

Xavier

Thanks! You may also want to check out the event handling and picking tutorial at

http://matplotlib.sourceforge.net/users/event_handling.html

JDH

···

On Tue, Mar 24, 2009 at 3:01 PM, Xavier Gnata <xavier.gnata@…287…> wrote:

I got some good tips on how to do this from

examples/event_handling/pick_event_demo.py

Thanks!! It works just fine :). IDL is dead. Qt4 python and

numpy/scipy/numpy are great tools.