Bug in matplotlib.patches' contains() method?

Hi,
I was trying to find out when a button_press_event happened inside a patch
(tried Circle and Rectangle) using the contains(mouseevent) method, but it
always seem to return True. I got the inspiration from the looking_glass.py
example, which also doesn't work as (Ithink) it should. I know Ican do this the
hard way, i.e. checking with event.xdata event.ydata, but I was really happy
there was already a pre-defined method for doing so.

Cheers,

Jorge

It shouldn't always return True -- it should return a tuple of type (bool, dict). The first element is whether it's inside, and the second is a dictionary of indices of subobjects (used only for Collections). Unfortunately, this tuple always evaluates to True. Have you tried changing your contains test from ".contains()" to ".contains()[0]"?

If that's not what's happening for you, can you send a self-contained example that illustrates this bug?

(I noticed the looking_glass.py example has this bug -- I'll fix that.)

Mike

ยทยทยท

On 11/28/2009 02:44 PM, Jorge Scandaliaris wrote:

Hi,
I was trying to find out when a button_press_event happened inside a patch
(tried Circle and Rectangle) using the contains(mouseevent) method, but it
always seem to return True. I got the inspiration from the looking_glass.py
example, which also doesn't work as (Ithink) it should. I know Ican do this the
hard way, i.e. checking with event.xdata event.ydata, but I was really happy
there was already a pre-defined method for doing so.

Cheers,

Jorge

------------------------------------------------------------------------------
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