Here is a modified version of the code. Note that since it uses
non-public APIs, it may stop to work again in the future. According to
your original post, you seem to want to pick up points only. I guess
the better way is to have a separate artists. One for points and the
other for line segments.

Regards,

-JJ


def contains_points(self, mouseevent):

    pickradius = self.pickradius

    # Make sure we have data to plot
    #if self._invalid:
    if self._invalidy or self._invalidx:
        self.recache()
    if len(self._xy)==0: return False,{}

    # Convert points to pixels
    if self._transformed_path is None:
        self._transform_path()
    path, affine = self._transformed_path.get_transformed_points_and_affine()
    path = affine.transform_path(path)
    xy = path.vertices
    xt = xy[:, 0]
    yt = xy[:, 1]

    pixels = self.figure.dpi/72. * self.pickradius

    d = (xt-mouseevent.x)**2 + (yt-mouseevent.y)**2
    ind, = np.nonzero(np.less_equal(d, pixels**2))

    # Return the point(s) within radius
    return len(ind)>0,dict(ind=ind)

On Mon, Dec 6, 2010 at 8:19 AM, C M <cmpyt...@gmail.com> wrote:
> Hello.  I upgraded from about mpl 0.98.5 to 1.0, and this code, which worked
> in 0.98.5:
>
>     if line._invalid:
>         line.recache()
>
> now gives this error:
>
>   AttributeError: 'Line2D' object has no attribute '_invalid'
>
> What is now (1.0) the right way to test whether a Line2D object is invalid?
>
> Thanks very much,
> Che
>
> (This question is in another recent post of mine, but this is much more to
> the point)
>
> ------------------------------------------------------------------------------
> What happens now with your Lotus Notes apps - do you make another costly
> upgrade, or settle for being marooned without product support? Time to move
> off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
> use, and manage than apps on traditional platforms. Sign up for the Lotus
> Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to