Skip to content

Commit 9687a2a

Browse files
authored
Merge pull request #22701 from meeseeksmachine/auto-backport-of-pr-22691-on-v3.5.x
Backport PR #22691 on branch v3.5.x (FIX: remove toggle on QuadMesh cursor data)
2 parents b02e3d6 + cdd86d1 commit 9687a2a

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

-5
This file was deleted.
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

-17
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,6 @@ def __init__(self, *args, **kwargs):
20112011
self._shading = shading
20122012
self._bbox = transforms.Bbox.unit()
20132013
self._bbox.update_from_data_xy(self._coordinates.reshape(-1, 2))
2014-
self._show_cursor_data = False
20152014
# super init delayed after own init because array kwarg requires
20162015
# self._coordinates and self._shading
20172016
super().__init__(**kwargs)
@@ -2210,23 +2209,7 @@ def draw(self, renderer):
22102209
renderer.close_group(self.__class__.__name__)
22112210
self.stale = False
22122211

2213-
def set_show_cursor_data(self, show_cursor_data):
2214-
"""
2215-
Set whether cursor data should be shown.
2216-
2217-
Notes
2218-
-----
2219-
This is set to `False` by default for new quad meshes. Showing cursor
2220-
data can have significant performance impacts for large meshes.
2221-
"""
2222-
self._show_cursor_data = show_cursor_data
2223-
2224-
def get_show_cursor_data(self):
2225-
return self._show_cursor_data
2226-
22272212
def get_cursor_data(self, event):
2228-
if not self._show_cursor_data:
2229-
return
22302213
contained, info = self.contains(event)
22312214
if len(info["ind"]) == 1:
22322215
ind, = info["ind"]

lib/matplotlib/tests/test_collections.py

-21
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
@@ -1044,26 +1043,6 @@ def test_array_wrong_dimensions():
10441043
pc.update_scalarmappable()
10451044

10461045

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

0 commit comments

Comments
 (0)