Skip to content

Commit ac834f4

Browse files
tacaswellImgBotApp
authored andcommitted
Backport PR matplotlib#22254: Disable QuadMesh cursor data by default
1 parent 9a389f2 commit ac834f4

3 files changed

Lines changed: 22 additions & 1183 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
QuadMesh cursor data disabled by default
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
Showing the cursor data of a `.QuadMesh` is now disabled by default, as it has
4+
significant performance issues with large meshes. To manually enable this
5+
use :meth:`.QuadMesh.set_show_cursor_data`.

‎lib/matplotlib/collections.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,7 @@ def __init__(self, *args, **kwargs):
19831983
self._shading = shading
19841984
self._bbox = transforms.Bbox.unit()
19851985
self._bbox.update_from_data_xy(self._coordinates.reshape(-1, 2))
1986+
self._show_cursor_data = False
19861987
# super init delayed after own init because array kwarg requires
19871988
# self._coordinates and self._shading
19881989
super().__init__(**kwargs)
@@ -2180,7 +2181,23 @@ def draw(self, renderer):
21802181
renderer.close_group(self.__class__.__name__)
21812182
self.stale = False
21822183

2184+
def set_show_cursor_data(self, show_cursor_data):
2185+
"""
2186+
Set whether cursor data should be shown.
2187+
2188+
Notes
2189+
-----
2190+
This is set to `False` by default for new quad meshes. Showing cursor
2191+
data can have significant performance impacts for large meshes.
2192+
"""
2193+
self._show_cursor_data = show_cursor_data
2194+
2195+
def get_show_cursor_data(self):
2196+
return self._show_cursor_data
2197+
21832198
def get_cursor_data(self, event):
2199+
if not self._show_cursor_data:
2200+
return
21842201
contained, info = self.contains(event)
21852202
if contained and self.get_array() is not None:
21862203
return self.get_array().ravel()[info["ind"]]

0 commit comments

Comments
 (0)