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

Skip to content

Commit 33d56d8

Browse files
committed
expose Path.contains_points as a method of Patch
`Patch` has the method `contains_point` but not `contains_points`, but the latter is supported by `Path`. This PR adds `contains_points` to `Patch`.
1 parent 37978a8 commit 33d56d8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/matplotlib/patches.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,29 @@ def contains(self, mouseevent, radius=None):
143143

144144
def contains_point(self, point, radius=None):
145145
"""
146-
Returns *True* if the given point is inside the path
146+
Returns `True` if the given point is inside the path
147147
(transformed with its transform attribute).
148+
149+
`radius` allows the path to be made slightly larger or smaller.
148150
"""
149151
radius = self._process_radius(radius)
150152
return self.get_path().contains_point(point,
151153
self.get_transform(),
152154
radius)
153155

156+
def contains_points(self, points, radius=None):
157+
"""
158+
Returns a bool array which is `True` if the (closed) path contains the corresponding point.
159+
(transformed with its transform attribute).
160+
161+
`points` should be an N x 2 array.
162+
`radius` allows the path to be made slightly larger or smaller.
163+
"""
164+
radius = self._process_radius(radius)
165+
return self.get_path().contains_points(points,
166+
self.get_transform(),
167+
radius)
168+
154169
def update_from(self, other):
155170
"""
156171
Updates this :class:`Patch` from the properties of *other*.

0 commit comments

Comments
 (0)