[Matplotlib-users] event.ind in point picking gives wrong number

2013-09-15 Thread C M
I have Matplotlib 1.1.0, and am doing point picking (using the OO approach
to Matplotlib, and embedded in wxPython).  My relevant code is as follows:

#connect the pick event to the pick event handler:
self.cid = self.canvas.mpl_connect('pick_event', self.on_pick)

#This is the relevant part of the pick event handler:
def on_pick(self, event):
if isinstance(event.artist, Line2D):
ind = event.ind
print 'ind is: ', str(ind)

This had been working in some cases, but I've found a case in which it
appears to be giving me a value for ind that doesn't make sense.  For
example, I have a plot with two lines on it (and two y axes), each with
over 50 points.  When I pick one of the points right near the end, I expect
the ind here will be about 50.  However, it prints ind is: 3.  In other
words, the wrong index value.  This is a serious issue for me, because I
then use that index to look up information about that point.

What could be going on here?

Thanks,
Che
--
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/22/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=64545871iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] event.ind in point picking gives wrong number

2013-09-15 Thread C M
Just a follow-up on this problem...

I've found now that the index is only off if the plot is zoomed, and in the
following way.  When I zoom, the first point that is visible in the plot
window will have index = 0, the next point will have index = 1, and so
forth.  If I zoom another section of the points, the indices are reset in
this same way.

What's really bizarre is that this is only occurring on one plot.  When I
try to reproduce the problem on other plots (so far at least), I can't.

Any suggestions for how to chase this down would be very welcome.

Thanks.


On Sun, Sep 15, 2013 at 5:30 PM, C M cmpyt...@gmail.com wrote:

 I have Matplotlib 1.1.0, and am doing point picking (using the OO approach
 to Matplotlib, and embedded in wxPython).  My relevant code is as follows:

 #connect the pick event to the pick event handler:
 self.cid = self.canvas.mpl_connect('pick_event', self.on_pick)

 #This is the relevant part of the pick event handler:
 def on_pick(self, event):
 if isinstance(event.artist, Line2D):
 ind = event.ind
 print 'ind is: ', str(ind)

 This had been working in some cases, but I've found a case in which it
 appears to be giving me a value for ind that doesn't make sense.  For
 example, I have a plot with two lines on it (and two y axes), each with
 over 50 points.  When I pick one of the points right near the end, I expect
 the ind here will be about 50.  However, it prints ind is: 3.  In other
 words, the wrong index value.  This is a serious issue for me, because I
 then use that index to look up information about that point.

 What could be going on here?

 Thanks,
 Che

--
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=58041151iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users