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

Skip to content

Commit 80c2fdc

Browse files
authored
Merge pull request #22691 from jklymak/fix-remove-quadmesh-cursor-data
FIX: remove toggle on QuadMesh cursor data (in favor of more general one)
2 parents 6b2d3f2 + 8971f1d commit 80c2fdc

File tree

4 files changed

+6
-43
lines changed

4 files changed

+6
-43
lines changed

doc/api/next_api_changes/behavior/22254-DS.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
QuadMesh mouseover defaults to False
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
New in 3.5, `.QuadMesh.get_cursor_data` allows display of data values
5+
under the cursor. However, this can be very slow for large meshes, so
6+
by `.QuadMesh.set_mouseover` defaults to *False*.

lib/matplotlib/collections.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,7 +1999,6 @@ def __init__(self, *args, **kwargs):
19991999
self._shading = shading
20002000
self._bbox = transforms.Bbox.unit()
20012001
self._bbox.update_from_data_xy(self._coordinates.reshape(-1, 2))
2002-
self._show_cursor_data = False
20032002
# super init delayed after own init because array kwarg requires
20042003
# self._coordinates and self._shading
20052004
super().__init__(**kwargs)
@@ -2198,23 +2197,7 @@ def draw(self, renderer):
21982197
renderer.close_group(self.__class__.__name__)
21992198
self.stale = False
22002199

2201-
def set_show_cursor_data(self, show_cursor_data):
2202-
"""
2203-
Set whether cursor data should be shown.
2204-
2205-
Notes
2206-
-----
2207-
This is set to `False` by default for new quad meshes. Showing cursor
2208-
data can have significant performance impacts for large meshes.
2209-
"""
2210-
self._show_cursor_data = show_cursor_data
2211-
2212-
def get_show_cursor_data(self):
2213-
return self._show_cursor_data
2214-
22152200
def get_cursor_data(self, event):
2216-
if not self._show_cursor_data:
2217-
return
22182201
contained, info = self.contains(event)
22192202
if len(info["ind"]) == 1:
22202203
ind, = info["ind"]

lib/matplotlib/tests/test_collections.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import matplotlib as mpl
99
import matplotlib.pyplot as plt
10-
from matplotlib.backend_bases import MouseEvent
1110
import matplotlib.collections as mcollections
1211
import matplotlib.colors as mcolors
1312
import matplotlib.transforms as mtransforms
@@ -1039,26 +1038,6 @@ def test_array_wrong_dimensions():
10391038
pc.update_scalarmappable()
10401039

10411040

1042-
def test_quadmesh_cursor_data():
1043-
fig, ax = plt.subplots()
1044-
*_, qm = ax.hist2d(
1045-
np.arange(11)**2, 100 + np.arange(11)**2) # width-10 bins
1046-
1047-
x, y = ax.transData.transform([1, 101])
1048-
event = MouseEvent('motion_notify_event', fig.canvas, x, y)
1049-
1050-
assert qm.get_show_cursor_data() is False
1051-
assert qm.get_cursor_data(event) is None
1052-
1053-
qm.set_show_cursor_data(True)
1054-
assert qm.get_cursor_data(event) == 4 # (0**2, 1**2, 2**2, 3**2)
1055-
1056-
# Outside the quadmesh bounds
1057-
x, y = ax.transData.transform([-1, 101])
1058-
event = MouseEvent('motion_notify_event', fig.canvas, x, y)
1059-
assert qm.get_cursor_data(event) is None
1060-
1061-
10621041
def test_get_segments():
10631042
segments = np.tile(np.linspace(0, 1, 256), (2, 1)).T
10641043
lc = LineCollection([segments])

0 commit comments

Comments
 (0)