Skip to content

Commit 2fa85ee

Browse files
tacaswelloscargusQuLogictimhoffm
authored
DOC: clarify the default value of *radius* in Patch.contains_point (#27462)
... and friends. closes #19807 Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com> Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com> Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent e427499 commit 2fa85ee

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

lib/matplotlib/patches.py

+50-3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,29 @@ def contains(self, mouseevent, radius=None):
127127
"""
128128
Test whether the mouse event occurred in the patch.
129129
130+
Parameters
131+
----------
132+
mouseevent : `~matplotlib.backend_bases.MouseEvent`
133+
Where the user clicked.
134+
135+
radius : float, optional
136+
Additional margin on the patch in target coordinates of
137+
`.Patch.get_transform`. See `.Path.contains_point` for further
138+
details.
139+
140+
If `None`, the default value depends on the state of the object:
141+
142+
- If `.Artist.get_picker` is a number, the default
143+
is that value. This is so that picking works as expected.
144+
- Otherwise if the edge color has a non-zero alpha, the default
145+
is half of the linewidth. This is so that all the colored
146+
pixels are "in" the patch.
147+
- Finally, if the edge has 0 alpha, the default is 0. This is
148+
so that patches without a stroked edge do not have points
149+
outside of the filled region report as "in" due to an
150+
invisible edge.
151+
152+
130153
Returns
131154
-------
132155
(bool, empty dict)
@@ -160,13 +183,25 @@ def contains_point(self, point, radius=None):
160183
----------
161184
point : (float, float)
162185
The point (x, y) to check, in target coordinates of
163-
``self.get_transform()``. These are display coordinates for patches
186+
``.Patch.get_transform()``. These are display coordinates for patches
164187
that are added to a figure or Axes.
165188
radius : float, optional
166189
Additional margin on the patch in target coordinates of
167-
``self.get_transform()``. See `.Path.contains_point` for further
190+
`.Patch.get_transform`. See `.Path.contains_point` for further
168191
details.
169192
193+
If `None`, the default value depends on the state of the object:
194+
195+
- If `.Artist.get_picker` is a number, the default
196+
is that value. This is so that picking works as expected.
197+
- Otherwise if the edge color has a non-zero alpha, the default
198+
is half of the linewidth. This is so that all the colored
199+
pixels are "in" the patch.
200+
- Finally, if the edge has 0 alpha, the default is 0. This is
201+
so that patches without a stroked edge do not have points
202+
outside of the filled region report as "in" due to an
203+
invisible edge.
204+
170205
Returns
171206
-------
172207
bool
@@ -214,9 +249,21 @@ def contains_points(self, points, radius=None):
214249
that are added to a figure or Axes. Columns contain x and y values.
215250
radius : float, optional
216251
Additional margin on the patch in target coordinates of
217-
``self.get_transform()``. See `.Path.contains_point` for further
252+
`.Patch.get_transform`. See `.Path.contains_point` for further
218253
details.
219254
255+
If `None`, the default value depends on the state of the object:
256+
257+
- If `.Artist.get_picker` is a number, the default
258+
is that value. This is so that picking works as expected.
259+
- Otherwise if the edge color has a non-zero alpha, the default
260+
is half of the linewidth. This is so that all the colored
261+
pixels are "in" the patch.
262+
- Finally, if the edge has 0 alpha, the default is 0. This is
263+
so that patches without a stroked edge do not have points
264+
outside of the filled region report as "in" due to an
265+
invisible edge.
266+
220267
Returns
221268
-------
222269
length-N bool array

0 commit comments

Comments
 (0)