@@ -1930,7 +1930,7 @@ def draw(self, renderer):
19301930
19311931
19321932class QuadMesh (Collection ):
1933- """
1933+ r """
19341934 Class for the efficient drawing of a quadrilateral mesh.
19351935
19361936 A quadrilateral mesh is a grid of M by N adjacent qudrilaterals that are
@@ -1957,6 +1957,10 @@ class QuadMesh(Collection):
19571957
19581958 Notes
19591959 -----
1960+ Unlike other `.Collection`\s, the default *pickradius* of `.QuadMesh` is 0,
1961+ i.e. `~.Artist.contains` checks whether the test point is within any of the
1962+ mesh quadrilaterals.
1963+
19601964 There exists a deprecated API version ``QuadMesh(M, N, coords)``, where
19611965 the dimensions are given explicitly and ``coords`` is a (M*N, 2)
19621966 array-like. This has been deprecated in Matplotlib 3.5. The following
@@ -1984,8 +1988,8 @@ class QuadMesh(Collection):
19841988 For example, the first entry in *coordinates* is the coordinates of the
19851989 vertex at mesh coordinates (0, 0), then the one at (0, 1), then at (0, 2)
19861990 .. (0, meshWidth), (1, 0), (1, 1), and so on.
1987-
19881991 """
1992+
19891993 def __init__ (self , * args , ** kwargs ):
19901994 # signature deprecation since="3.5": Change to new signature after the
19911995 # deprecation has expired. Also remove setting __init__.__signature__,
@@ -2017,6 +2021,7 @@ def __init__(self, *args, **kwargs):
20172021 "coordinates must be 2D; all parameters except "
20182022 "coordinates will be keyword-only." )
20192023 coords = np .asarray (coords , np .float64 ).reshape ((h + 1 , w + 1 , 2 ))
2024+ kwargs .setdefault ("pickradius" , 0 )
20202025 # end of signature deprecation code
20212026
20222027 super ().__init__ (** kwargs )
@@ -2031,7 +2036,7 @@ def __init__(self, *args, **kwargs):
20312036 # Only needed during signature deprecation
20322037 __init__ .__signature__ = inspect .signature (
20332038 lambda self , coordinates , * ,
2034- antialiased = True , shading = 'flat' , ** kwargs : None )
2039+ antialiased = True , shading = 'flat' , pickradius = 0 , ** kwargs : None )
20352040
20362041 def get_paths (self ):
20372042 if self ._paths is None :
@@ -2172,3 +2177,11 @@ def draw(self, renderer):
21722177 gc .restore ()
21732178 renderer .close_group (self .__class__ .__name__ )
21742179 self .stale = False
2180+
2181+ def get_cursor_data (self , event ):
2182+ contained , info = self .contains (event )
2183+ if len (info ["ind" ]) == 1 :
2184+ ind , = info ["ind" ]
2185+ return self .get_array ()[ind ]
2186+ else :
2187+ return None
0 commit comments