Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5505989

Browse files
authored
Merge branch 'main' into yc-task2-tests
2 parents 1226060 + 844fcc8 commit 5505989

File tree

5 files changed

+12
-31
lines changed

5 files changed

+12
-31
lines changed

lib/matplotlib/artist.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def get_picker(self):
595595
set_picker, pickable, pick
596596
"""
597597
return self._picker
598-
598+
599599
def hoverable(self):
600600
"""
601601
Return whether the artist is hoverable.
@@ -605,7 +605,7 @@ def hoverable(self):
605605
set_hover, get_hover, hover
606606
"""
607607
return self.figure is not None and self._hover is not None
608-
608+
609609
def hover(self, mouseevent):
610610
"""
611611
Process a hover event.
@@ -624,7 +624,7 @@ def hover(self, mouseevent):
624624
inside, prop = self.contains(mouseevent)
625625
if inside:
626626
HoverEvent("hover_event", self.figure.canvas,
627-
mouseevent, self, **prop)._process()
627+
mouseevent, self, **prop)._process()
628628

629629
# Pick children
630630
for a in self.get_children():
@@ -640,28 +640,14 @@ def set_hover(self, hover):
640640
641641
Parameters
642642
----------
643-
hover : None or bool or float or function
643+
hover : None or bool
644644
This can be one of the following:
645645
646646
- *None*: Hover is disabled for this artist (default).
647647
648648
- A boolean: If *True* then hover will be enabled and the
649649
artist will fire a hover event if the mouse event is hovering over
650650
the artist.
651-
652-
- A float: If hover is a number it is interpreted as an
653-
epsilon tolerance in points and the artist will fire
654-
off an event if its data is within epsilon of the mouse
655-
event. For some artists like lines and patch collections,
656-
the artist may provide additional data to the hover event
657-
that is generated, e.g., the indices of the data within
658-
epsilon of the hover event
659-
660-
- A function: If hover is callable, it is a user supplied
661-
function which determines whether the artist is hit by the
662-
mouse event to determine the hit test. If the mouse event
663-
is over the artist, return *hit=True* and props is a dictionary of
664-
properties you want added to the HoverEvent attributes.
665651
"""
666652
if not self.figure and hover is not None:
667653
raise ValueError("Cannot hover without an existing figure")

lib/matplotlib/artist.pyi

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,10 @@ class Artist:
7676
) -> None | bool | float | Callable[
7777
[Artist, MouseEvent], tuple[bool, dict[Any, Any]]
7878
]: ...
79-
def set_hover(
80-
self,
81-
hover: None
82-
| bool
83-
| float
84-
| Callable[[Artist, MouseEvent], str],
85-
) -> None: ...
86-
def get_hover(
87-
self,
88-
) -> None | bool | float | Callable[
89-
[Artist, MouseEvent], str
90-
]: ...
79+
def hoverable(self) -> bool: ...
80+
def hover(self, mouseevent: MouseEvent) -> None: ...
81+
def set_hover(self, hover: None | bool) -> None: ...
82+
def get_hover(self) -> None | bool: ...
9183
def get_url(self) -> str | None: ...
9284
def set_url(self, url: str | None) -> None: ...
9385
def get_gid(self) -> str | None: ...

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3016,7 +3016,8 @@ def mouse_move(self, event):
30163016
self.set_message(self._mouse_event_to_message(event))
30173017

30183018
if callable(getattr(self, 'set_hover_message', None)):
3019-
for a in self.canvas.figure.findobj(match=lambda x: not isinstance(x, Rectangle), include_self=False):
3019+
for a in self.canvas.figure.findobj(match=lambda x: not isinstance(x,
3020+
Rectangle), include_self=False):
30203021
inside, prop = a.contains(event)
30213022
if inside:
30223023
self.set_hover_message(self._mouse_event_to_message(event))

lib/matplotlib/backends/_backend_tk.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,7 @@ def set_message(self, s):
10501050
def set_hover_message(self, s):
10511051
self._hover_message.set(s)
10521052

1053+
10531054
@backend_tools._register_tool_class(FigureCanvasTk)
10541055
class SaveFigureTk(backend_tools.SaveFigureBase):
10551056
def trigger(self, *args):

lib/matplotlib/figure.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ class Figure(FigureBase):
321321
**kwargs
322322
) -> None: ...
323323
def pick(self, mouseevent: MouseEvent) -> None: ...
324+
def hover(self, mouseevent: MouseEvent) -> None: ...
324325
def set_layout_engine(
325326
self,
326327
layout: Literal["constrained", "compressed", "tight", "none"]

0 commit comments

Comments
 (0)