Return whether the area enclosed by the path contains the given point. 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, point, transform=None, radius=0.0)
| 519 | self._interpolation_steps) |
| 520 | |
| 521 | def contains_point(self, point, transform=None, radius=0.0): |
| 522 | """ |
| 523 | Return whether the area enclosed by the path contains the given point. |
| 524 | |
| 525 | The path is always treated as closed; i.e. if the last code is not |
| 526 | `CLOSEPOLY` an implicit segment connecting the last vertex to the first |
| 527 | vertex is assumed. |
| 528 | |
| 529 | Parameters |
| 530 | ---------- |
| 531 | point : (float, float) |
| 532 | The point (x, y) to check. |
| 533 | transform : `~matplotlib.transforms.Transform`, optional |
| 534 | If not ``None``, *point* will be compared to ``self`` transformed |
| 535 | by *transform*; i.e. for a correct check, *transform* should |
| 536 | transform the path into the coordinate system of *point*. |
| 537 | radius : float, default: 0 |
| 538 | Additional margin on the path in coordinates of *point*. |
| 539 | The path is extended tangentially by *radius/2*; i.e. if you would |
| 540 | draw the path with a linewidth of *radius*, all points on the line |
| 541 | would still be considered to be contained in the area. Conversely, |
| 542 | negative values shrink the area: Points on the imaginary line |
| 543 | will be considered outside the area. |
| 544 | |
| 545 | Returns |
| 546 | ------- |
| 547 | bool |
| 548 | |
| 549 | Notes |
| 550 | ----- |
| 551 | The current algorithm has some limitations: |
| 552 | |
| 553 | - The result is undefined for points exactly at the boundary |
| 554 | (i.e. at the path shifted by *radius/2*). |
| 555 | - The result is undefined if there is no enclosed area, i.e. all |
| 556 | vertices are on a straight line. |
| 557 | - If bounding lines start to cross each other due to *radius* shift, |
| 558 | the result is not guaranteed to be correct. |
| 559 | """ |
| 560 | if transform is not None: |
| 561 | transform = transform.frozen() |
| 562 | # `point_in_path` does not handle nonlinear transforms, so we |
| 563 | # transform the path ourselves. If *transform* is affine, letting |
| 564 | # `point_in_path` handle the transform avoids allocating an extra |
| 565 | # buffer. |
| 566 | if transform and not transform.is_affine: |
| 567 | self = transform.transform_path(self) |
| 568 | transform = None |
| 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 | """ |
no test coverage detected