-
craftutils.observation.image.Ellipse.contains_point(point, radius=
None) Return whether the given point is inside the patch.
Parameters¶
- point(float, float)
The point (x, y) to check, in target coordinates of
self.get_transform(). These are display coordinates for patches that are added to a figure or axes.- radiusfloat, optional
Additional margin on the patch in target coordinates of
self.get_transform(). See .Path.contains_point for further details.
Returns¶
bool
Notes¶
The proper use of this method depends on the transform of the patch. Isolated patches do not have a transform. In this case, the patch creation coordinates and the point coordinates match. The following example checks that the center of a circle is within the circle
>>> center = 0, 0 >>> c = Circle(center, radius=1) >>> c.contains_point(center) TrueThe convention of checking against the transformed patch stems from the fact that this method is predominantly used to check if display coordinates (e.g. from mouse events) are within the patch. If you want to do the above check with data coordinates, you have to properly transform them first:
>>> center = 0, 0 >>> c = Circle(center, radius=1) >>> plt.gca().add_patch(c) >>> transformed_center = c.get_transform().transform(center) >>> c.contains_point(transformed_center) True