qt4: Transforming to display coordinates

Hi John,

thank you four your helpful answer.

John Hunter <jdh2358@...287...> writes:

   def on_move(self, event)
       mouse_pos_diag_x = ???(event.xdata)
       mouse_pos_diag_y = ???(event.ydata)
where I would need to replace the ??? with some transformation from
event.xdata, event.ydata, and the min and max of the y axis. How could I
do that?

The mouse event object already has display coords attached in the
event.x and event.y attributes.

My example was a bit simplified. What I want to do is to connect several
diagrams to show the same cursor. For the diagram with the mouse in it,
I can get ofcourse pixel coordinates, too. But for all other diagrams I
need to convert the cursor position to pixel coordinates.

But to answer your question about matplotlib transforms. You could do
  ax = event.inaxes # the axes the event occurred in
  x, y = ax.transData.transform_point((event.xdata, event.ydata))

This is exactly what I need. Does the reverse transformation also exist?

Cheers

Ole

···

On Thu, Jun 4, 2009 at 8:49 AM, Ole Streicher <ole-usenet-spam@...361...> wrote:

Yes:

  xdata, ydata = ax.transData.inverted().transform_point((xdisplay, ydisplay))

And the transAxes attribute maps 0..1 relative axes position to display.

JDH

···

On Thu, Jun 4, 2009 at 9:26 AM, Ole Streicher <ole-usenet-spam@...361...> wrote:

But to answer your question about matplotlib transforms. You could do
  ax = event.inaxes # the axes the event occurred in
  x, y = ax.transData.transform_point((event.xdata, event.ydata))