MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / contains_points

Method contains_points

lib/matplotlib/path.py:571–613  ·  view source on GitHub ↗

Return whether the area enclosed by the path contains the given points. The path is always treated as closed; i.e. if the last code is not `CLOSEPOLY` an implicit segment connecting the last vertex to the first vertex is assumed. Parameters --------

(self, points, transform=None, radius=0.0)

Source from the content-addressed store, hash-verified

569 return _path.point_in_path(point[0], point[1], radius, self, transform)
570
571 def contains_points(self, points, transform=None, radius=0.0):
572 """
573 Return whether the area enclosed by the path contains the given points.
574
575 The path is always treated as closed; i.e. if the last code is not
576 `CLOSEPOLY` an implicit segment connecting the last vertex to the first
577 vertex is assumed.
578
579 Parameters
580 ----------
581 points : (N, 2) array
582 The points to check. Columns contain x and y values.
583 transform : `~matplotlib.transforms.Transform`, optional
584 If not ``None``, *points* will be compared to ``self`` transformed
585 by *transform*; i.e. for a correct check, *transform* should
586 transform the path into the coordinate system of *points*.
587 radius : float, default: 0
588 Additional margin on the path in coordinates of *points*.
589 The path is extended tangentially by *radius/2*; i.e. if you would
590 draw the path with a linewidth of *radius*, all points on the line
591 would still be considered to be contained in the area. Conversely,
592 negative values shrink the area: Points on the imaginary line
593 will be considered outside the area.
594
595 Returns
596 -------
597 length-N bool array
598
599 Notes
600 -----
601 The current algorithm has some limitations:
602
603 - The result is undefined for points exactly at the boundary
604 (i.e. at the path shifted by *radius/2*).
605 - The result is undefined if there is no enclosed area, i.e. all
606 vertices are on a straight line.
607 - If bounding lines start to cross each other due to *radius* shift,
608 the result is not guaranteed to be correct.
609 """
610 if transform is not None:
611 transform = transform.frozen()
612 result = _path.points_in_path(points, radius, self, transform)
613 return result.astype('bool')
614
615 def contains_path(self, path, transform=None):
616 """

Callers 7

test_point_in_path_nanFunction · 0.95
onselectMethod · 0.95
onselectMethod · 0.95
test_point_in_pathFunction · 0.45
test_contains_pointsFunction · 0.45
callbackMethod · 0.45

Calls 1

frozenMethod · 0.45

Tested by 4

test_point_in_path_nanFunction · 0.76
test_point_in_pathFunction · 0.36
test_contains_pointsFunction · 0.36