Cursor position

Hi,

I'm interested in controlling how the cursor position appears at the bottom
of interactive windows.

I noticed that by default, it is the Formatter that gets called. However, in
my case, the displayed coordinates each depend on both the x and y pixel
value, and therefore I need to somehow override the Formatter.

Does anyone have any suggestions? Should I use event handling with the
'motion_notify_event' event? If so, how do I make sure that the formatter
doesn't still get called, and where is the string object that I should
update?

Thanks,

Thomas

···

--
View this message in context: http://www.nabble.com/Cursor-position-tp25119919p25119919.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Hi,

I'm interested in controlling how the cursor position appears at the bottom
of interactive windows.

I noticed that by default, it is the Formatter that gets called. However, in
my case, the displayed coordinates each depend on both the x and y pixel
value, and therefore I need to somehow override the Formatter.

I doubt if overriding formatter works. Formatter basically does not
know about the other coordinate.

I think the easiest solution is to override the Axes.format_coord. For example,

  ax = gca()
  ax.format_coord = lambda x,y : "x=%g y=%g" % (x, y)

x,y are in data coordinate. I'm not sure if there is any side effect,
but it seems that the format_coord method is only used to display the
coordinate in the toolbar.

Does anyone have any suggestions? Should I use event handling with the
'motion_notify_event' event? If so, how do I make sure that the formatter
doesn't still get called, and where is the string object that I should
update?

Take a look at the NavigationToolbar2 class in backend_bases.py.
If you go down this road, you may need to modify mouse_move method to
prevent it displaying the coordinate. You may use set_message method
to display the coordinate.

But I personally think overriding format_coord method is good enough.

Regards,

-JJ

···

On Mon, Aug 24, 2009 at 1:14 PM, Thomas Robitaille<thomas.robitaille@...287...> wrote:

Thanks,

Thomas
--
View this message in context: http://www.nabble.com/Cursor-position-tp25119919p25119919.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

I think the easiest solution is to override the Axes.format_coord. For example,

ax = gca()
ax.format_coord = lambda x,y : "x=%g y=%g" % (x, y)

x,y are in data coordinate. I'm not sure if there is any side effect,
but it seems that the format_coord method is only used to display the
coordinate in the toolbar.

This is exactly what I needed - thanks!

Tom