|
46 | 46 | from numpy.linalg import inv
|
47 | 47 |
|
48 | 48 | from matplotlib import _api
|
49 |
| -from matplotlib._path import ( |
50 |
| - affine_transform, count_bboxes_overlapping_bbox, update_path_extents) |
| 49 | +from matplotlib._path import affine_transform, count_bboxes_overlapping_bbox |
51 | 50 | from .path import Path
|
52 | 51 |
|
53 | 52 | DEBUG = False
|
@@ -868,10 +867,35 @@ def update_from_path(self, path, ignore=None, updatex=True, updatey=True):
|
868 | 867 | if path.vertices.size == 0:
|
869 | 868 | return
|
870 | 869 |
|
871 |
| - points, minpos, changed = update_path_extents( |
872 |
| - path, None, self._points, self._minpos, ignore) |
| 870 | + if ignore: |
| 871 | + points = np.array([[np.inf, np.inf], [-np.inf, -np.inf]]) |
| 872 | + minpos = np.array([np.inf, np.inf]) |
| 873 | + else: |
| 874 | + points = self._points.copy() |
| 875 | + minpos = self._minpos.copy() |
| 876 | + |
| 877 | + if updatex and updatey: |
| 878 | + where = (np.isfinite(path.vertices[..., 0]) |
| 879 | + & np.isfinite(path.vertices[..., 1])) |
| 880 | + elif updatex: |
| 881 | + where = np.isfinite(path.vertices[..., 0]) |
| 882 | + elif updatey: |
| 883 | + where = np.isfinite(path.vertices[..., 1]) |
| 884 | + else: |
| 885 | + return |
873 | 886 |
|
874 |
| - if changed: |
| 887 | + if updatex: |
| 888 | + x = path.vertices[..., 0][where] |
| 889 | + points[0, 0] = min(points[0, 0], np.min(x, initial=np.inf)) |
| 890 | + points[1, 0] = max(points[1, 0], np.max(x, initial=-np.inf)) |
| 891 | + minpos[0] = min(minpos[0], np.min(x[x > 0], initial=np.inf)) |
| 892 | + if updatey: |
| 893 | + y = path.vertices[..., 1][where] |
| 894 | + points[0, 1] = min(points[0, 1], np.min(y, initial=np.inf)) |
| 895 | + points[1, 1] = max(points[1, 1], np.max(y, initial=-np.inf)) |
| 896 | + minpos[1] = min(minpos[1], np.min(y[y > 0], initial=np.inf)) |
| 897 | + |
| 898 | + if np.any(points != self._points) or np.any(minpos != self._minpos): |
875 | 899 | self.invalidate()
|
876 | 900 | if updatex:
|
877 | 901 | self._points[:, 0] = points[:, 0]
|
|
0 commit comments