(self, event)
This is basically a proxy to trigger a pick event.  This function is
        connected to either a mouse motion or mouse button event (see
        "self.enable") depending on "self.hover". If we're over a point, it
        fires a pick event.

        This probably seems bizarre, but it's required for hover mode (no mouse
        click) and otherwise it's a workaround for picking artists in twinned
        or overlapping axes.

        Even if we're not in hover mode, pick events won't work properly for
        twinned axes.  Therefore, we manually go through all artists managed by
        this datacursor and fire a pick event if the mouse is over an a managed
        artist.
This is basically a proxy to trigger a pick event.  This function is
        connected to either a mouse motion or mouse button event (see
        "self.enable") depending on "self.hover". If we're over a point, it
        fires a pick event.
This is basically a proxy to trigger a pick event . This function is connected to either a mouse motion or mouse button event ( see self . enable ) depending on self . hover . If we re over a point it fires a pick event .
def _select(self, event):
        """This is basically a proxy to trigger a pick event.  This function is
        connected to either a mouse motion or mouse button event (see
        "self.enable") depending on "self.hover". If we're over a point, it
        fires a pick event.

        This probably seems bizarre, but it's required for hover mode (no mouse
        click) and otherwise it's a workaround for picking artists in twinned
        or overlapping axes.

        Even if we're not in hover mode, pick events won't work properly for
        twinned axes.  Therefore, we manually go through all artists managed by
        this datacursor and fire a pick event if the mouse is over an a managed
        artist."""
        def event_axes_data(event, ax):
            """Creates a new event will have xdata and ydata based on *ax*."""
            # We need to redefine event.xdata and event.ydata for twinned axes
            # to work correctly
            point = event.x, event.y
            x, y = ax.transData.inverted().transform_point(point)
            event = copy.copy(event)
            event.xdata, event.ydata = x, y
            return event

        def contains(artist, event):
            """Need to ensure we don't trigger a pick event for axes in a
            different figure. Otherwise, picking on one figure will trigger a
            datacursor in another figure."""
            if event.canvas is artist.figure.canvas:
                return artist.contains(event)
            else:
                return False, {}

        # If we're on top of an annotation box, hide it if right-clicked or
        # do nothing if we're in draggable mode
        for anno in list(self.annotations.values()):
            fixed_event = event_axes_data(event, anno.axes)
            if contains(anno, fixed_event)[0]:
                if event.button == self.hide_button:
                    self._hide_box(anno)
                elif self.draggable:
                    return

        for artist in self.artists:
            fixed_event = event_axes_data(event, artist.axes)
            inside, info = contains(artist, fixed_event)
            if inside:
                fig = artist.figure
                new_event = PickEvent('pick_event', fig.canvas, fixed_event,
                                     artist, **info)
                self(new_event)

                # Only fire a single pick event for one mouseevent. Otherwise
                # we'll need timers, etc to avoid multiple calls
                break

        # Not hovering over anything...
        if self.hover:
            artists = itertools.chain(self.artists, self.annotations.values())
            over_something = [contains(artist, event)[0] for artist in artists]
            if not any(over_something):
                self.hide()
def _select ( self , event ) : def event_axes_data ( event , ax ) : """Creates a new event will have xdata and ydata based on *ax*.""" # We need to redefine event.xdata and event.ydata for twinned axes # to work correctly point = event . x , event . y x , y = ax . transData . inverted ( ) . transform_point ( point ) event = copy . copy ( event ) event . xdata , event . ydata = x , y return event def contains ( artist , event ) : """Need to ensure we don't trigger a pick event for axes in a
            different figure. Otherwise, picking on one figure will trigger a
            datacursor in another figure.""" if event . canvas is artist . figure . canvas : return artist . contains ( event ) else : return False , { } # If we're on top of an annotation box, hide it if right-clicked or # do nothing if we're in draggable mode for anno in list ( self . annotations . values ( ) ) : fixed_event = event_axes_data ( event , anno . axes ) if contains ( anno , fixed_event ) [ 0 ] : if event . button == self . hide_button : self . _hide_box ( anno ) elif self . draggable : return for artist in self . artists : fixed_event = event_axes_data ( event , artist . axes ) inside , info = contains ( artist , fixed_event ) if inside : fig = artist . figure new_event = PickEvent ( 'pick_event' , fig . canvas , fixed_event , artist , * * info ) self ( new_event ) # Only fire a single pick event for one mouseevent. Otherwise # we'll need timers, etc to avoid multiple calls break # Not hovering over anything... if self . hover : artists = itertools . chain ( self . artists , self . annotations . values ( ) ) over_something = [ contains ( artist , event ) [ 0 ] for artist in artists ] if not any ( over_something ) : self . hide ( )