@@ -596,34 +596,58 @@ def get_picker(self):
596596 """
597597 return self ._picker
598598
599+ def hoverable (self ):
600+ """
601+ Return whether the artist is hoverable.
602+
603+ See Also
604+ --------
605+ set_hover, get_hover, hover
606+ """
607+ return self .figure is not None and self ._hover is not None
608+
609+ def hover (self , mouseevent ):
610+ """
611+ Process a hover event.
612+
613+ Each child artist will fire a hover event if *mouseevent* is over
614+ the artist and the artist has hover set.
615+
616+ See Also
617+ --------
618+ set_hover, get_hover, hoverable
619+ """
620+ from .backend_bases import HoverEvent # Circular import.
621+ # Hover self
622+ if self .hoverable ():
623+ hoverer = self .get_hover ()
624+ inside , prop = self .contains (mouseevent )
625+ if inside :
626+ HoverEvent ("hover_event" , self .figure .canvas ,
627+ mouseevent , self , ** prop )._process ()
628+
629+ # Pick children
630+ for a in self .get_children ():
631+ # make sure the event happened in the same Axes
632+ ax = getattr (a , 'axes' , None )
633+ if (mouseevent .inaxes is None or ax is None
634+ or mouseevent .inaxes == ax ):
635+ a .hover (mouseevent )
636+
599637 def set_hover (self , hover ):
600638 """
601639 Define the hover status of the artist.
602640
603641 Parameters
604642 ----------
605- hover : None or bool or float or callable
643+ hover : None or bool
606644 This can be one of the following:
607645
608646 - *None*: Hover is disabled for this artist (default).
609647
610648 - A boolean: If *True* then hover will be enabled and the
611649 artist will fire a hover event if the mouse event is hovering over
612650 the artist.
613-
614- - A float: If hover is a number it is interpreted as an
615- epsilon tolerance in points and the artist will fire
616- off an event if its data is within epsilon of the mouse
617- event. For some artists like lines and patch collections,
618- the artist may provide additional data to the hover event
619- that is generated, e.g., the indices of the data within
620- epsilon of the hover event
621-
622- - A function: If hover is callable, it is a user supplied
623- function which determines whether the artist is hit by the
624- mouse event to determine the hit test. if the mouse event
625- is over the artist, return *hit=True* and props is a dictionary of
626- properties you want added to the HoverEvent attributes.
627651 """
628652 self ._hover = hover
629653
0 commit comments