(self)
return self
Connects callbacks and makes artists pickable. If the datacursor has
        already been enabled, this function has no effect.
Connects callbacks and makes artists pickable. If the datacursor has
        already been enabled, this function has no effect.
Connects callbacks and makes artists pickable . If the datacursor has already been enabled this function has no effect .
def enable(self):
        """Connects callbacks and makes artists pickable. If the datacursor has
        already been enabled, this function has no effect."""
        def connect(fig):
            if self.hover:
                event = 'motion_notify_event'
            else:
                event = 'button_press_event'
            cids = [fig.canvas.mpl_connect(event, self._select)]

            # None of this should be necessary. Workaround for a bug in some
            # mpl versions
            try:
                proxy = fig.canvas.callbacks.BoundMethodProxy(self)
                fig.canvas.callbacks.callbacks[event][cids[-1]] = proxy
            except AttributeError:
                # In some versions of mpl, BoundMethodProxy doesn't exist...
                # See: https://github.com/joferkington/mpldatacursor/issues/2
                pass
            return cids

        if not getattr(self, '_enabled', False):
            self._cids = [(fig, connect(fig)) for fig in self.figures]
            self._enabled = True
            try:
                # Newer versions of MPL use set_pickradius
                for artist in self.artists:
                    artist.set_pickradius(self.tolerance)
            except AttributeError:
                # Older versions of MPL control pick radius through set_picker
                for artist in self.artists:
                    artist.set_picker(self.tolerance)

        return self
def enable ( self ) : def connect ( fig ) : if self . hover : event = 'motion_notify_event' else : event = 'button_press_event' cids = [ fig . canvas . mpl_connect ( event , self . _select ) ] # None of this should be necessary. Workaround for a bug in some # mpl versions try : proxy = fig . canvas . callbacks . BoundMethodProxy ( self ) fig . canvas . callbacks . callbacks [ event ] [ cids [ - 1 ] ] = proxy except AttributeError : # In some versions of mpl, BoundMethodProxy doesn't exist... # See: https://github.com/joferkington/mpldatacursor/issues/2 pass return cids if not getattr ( self , '_enabled' , False ) : self . _cids = [ ( fig , connect ( fig ) ) for fig in self . figures ] self . _enabled = True try : # Newer versions of MPL use set_pickradius for artist in self . artists : artist . set_pickradius ( self . tolerance ) except AttributeError : # Older versions of MPL control pick radius through set_picker for artist in self . artists : artist . set_picker ( self . tolerance ) return self