Re: [Matplotlib-users] Probing scalar values...

2007-08-06 Thread Angus McMorland
On 07/08/07, fred [EMAIL PROTECTED] wrote:
 Angus McMorland a écrit :

  Since all sorts of data can be displayed in am mpl window (e.g. a
  plot, a contour...) you have to tell it how to access the correct
  scalar value to display. You could do this with the
  motion_notify_event. Register it during init, something like:
 
  self.canvas.mpl_connect('motion_notify_event', self.mouse_move_callback)
 
  then in mouse_move_callback:
 
  def mouse_move_callback(self, evt):
  xpos, ypos = evt.xdata, evt.ydata
  val = self.data[numpy.floor(xpos), numpy.floor(ypos)]
  status_str = x: %4.2f  y: %4.2f   I:%4.2f \
% (xpos, ypos, val)
  self.SetStatusText(status_str)
 
  where data is your image variable. This works in a wx.Frame object,
  which has a SetStatusString method for displaying the values. I'm sure
  you could find an equivalent in your traits app.
 
 
 Thanks, I'll look at this asap (as I got other stuff on fire).

 BTW, I can't ever get (in fact, I don't know how) working
 the coords to be displayed in my traits app.
 I guess this is more related to traits, not to mpl.

For what it's worth, mpl embedded in wx also _requires_ the use of
motion_notify_event to get co-ordinates to display. It doesn't happen
by default except in stand-alone mpl as far as I can tell.

 But the mpl embedded in traits app guru is on holydays for now.

 Let's wait...

 Cheers,

 --
 http://scipy.org/FredericPetit


 -
 This SF.net email is sponsored by: Splunk Inc.
 Still grepping through log files to find problems?  Stop.
 Now Search log events and configuration files using AJAX and a browser.
 Download your FREE copy of Splunk now   http://get.splunk.com/
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



-- 
AJC McMorland, PhD Student
Physiology, University of Auckland

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Probing scalar values...

2007-08-03 Thread fred
John Hunter a écrit :
 But you can just ask us -- maybe we can help.
   
Ok.

Well, running mpl examples (say image_demo.py),
you can see the point coordinates under the pointer.
Good point ;-)

I would like to have the scalar value under the pointer to be displayed
too.

How could I do this ?

In fact, I use mpl in a traits app,
which looks like this:
http://fredantispam.free.fr/mpl.png

In my traits app, no point coords under pointer are displayed.

Am I missing something obvious ?

snippet code:
da = self.display.axes
self.img = da.imshow(self.current_data.array,
 vmin=self.vmin, vmax=self.vmax,
 cmap=self.cmap,
 interpolation=self.interpolate_colormap_method,
 extent=extent,
 origin=self.origin,
 alpha=self.opacity)
self.display.figure.canvas.draw()

TIA.

Cheers,

-- 
http://scipy.org/FredericPetit


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Probing scalar values...

2007-08-03 Thread Angus McMorland
Hi fred,

On 04/08/07, fred [EMAIL PROTECTED] wrote:
 Well, running mpl examples (say image_demo.py),
 you can see the point coordinates under the pointer.
 Good point ;-)

 I would like to have the scalar value under the pointer to be displayed
 too.

 How could I do this ?

Since all sorts of data can be displayed in am mpl window (e.g. a
plot, a contour...) you have to tell it how to access the correct
scalar value to display. You could do this with the
motion_notify_event. Register it during init, something like:

self.canvas.mpl_connect('motion_notify_event', self.mouse_move_callback)

then in mouse_move_callback:

def mouse_move_callback(self, evt):
xpos, ypos = evt.xdata, evt.ydata
val = self.data[numpy.floor(xpos), numpy.floor(ypos)]
status_str = x: %4.2f  y: %4.2f   I:%4.2f \
  % (xpos, ypos, val)
self.SetStatusText(status_str)

where data is your image variable. This works in a wx.Frame object,
which has a SetStatusString method for displaying the values. I'm sure
you could find an equivalent in your traits app.

Hope that helps,

Gus.
-- 
AJC McMorland, PhD Student
Physiology, University of Auckland

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users