Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 95463c3

Browse filesBrowse files
authored
Merge pull request #21545 from anntzer/getset_mouseover
Turn mouseover into a mpl-style getset_property.
2 parents 3d7dea5 + 39f41f5 commit 95463c3
Copy full SHA for 95463c3

File tree

Expand file treeCollapse file tree

3 files changed

+25
-13
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+25
-13
lines changed

‎doc/api/artist_api.rst

Copy file name to clipboardExpand all lines: doc/api/artist_api.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Interactive
3535
Artist.pchanged
3636
Artist.get_cursor_data
3737
Artist.format_cursor_data
38+
Artist.set_mouseover
39+
Artist.get_mouseover
3840
Artist.mouseover
3941
Artist.contains
4042
Artist.pick

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+22-12Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,28 +1295,38 @@ def format_cursor_data(self, data):
12951295
if isinstance(item, Number))
12961296
return "[" + data_str + "]"
12971297

1298-
@property
1299-
def mouseover(self):
1298+
def get_mouseover(self):
13001299
"""
1301-
If this property is set to *True*, the artist will be queried for
1302-
custom context information when the mouse cursor moves over it.
1303-
1304-
See also :meth:`get_cursor_data`, :class:`.ToolCursorPosition` and
1305-
:class:`.NavigationToolbar2`.
1300+
Return whether this artist is queried for custom context information
1301+
when the mouse cursor moves over it.
13061302
"""
13071303
return self._mouseover
13081304

1309-
@mouseover.setter
1310-
def mouseover(self, val):
1311-
val = bool(val)
1312-
self._mouseover = val
1305+
def set_mouseover(self, mouseover):
1306+
"""
1307+
Set whether this artist is queried for custom context information when
1308+
the mouse cursor moves over it.
1309+
1310+
Parameters
1311+
----------
1312+
mouseover : bool
1313+
1314+
See Also
1315+
--------
1316+
get_cursor_data
1317+
.ToolCursorPosition
1318+
.NavigationToolbar2
1319+
"""
1320+
self._mouseover = bool(mouseover)
13131321
ax = self.axes
13141322
if ax:
1315-
if val:
1323+
if self._mouseover:
13161324
ax._mouseover_set.add(self)
13171325
else:
13181326
ax._mouseover_set.discard(self)
13191327

1328+
mouseover = property(get_mouseover, set_mouseover) # backcompat.
1329+
13201330

13211331
def _get_tightbbox_for_layout_only(obj, *args, **kwargs):
13221332
"""

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ def _set_artist_props(self, a):
11031103
a.set_transform(self.transData)
11041104

11051105
a.axes = self
1106-
if a.mouseover:
1106+
if a.get_mouseover():
11071107
self._mouseover_set.add(a)
11081108

11091109
def _gen_axes_patch(self):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.