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

Method update_from_path

lib/matplotlib/transforms.py:873–931  ·  view source on GitHub ↗

Update the bounds of the `Bbox` to contain the vertices of the provided path. After updating, the bounds will have positive *width* and *height*; *x0* and *y0* will be the minimal values. Parameters ---------- path : `~matplotlib.path.Path` i

(self, path, ignore=None, updatex=True, updatey=True)

Source from the content-addressed store, hash-verified

871 self._ignore = value
872
873 def update_from_path(self, path, ignore=None, updatex=True, updatey=True):
874 """
875 Update the bounds of the `Bbox` to contain the vertices of the
876 provided path. After updating, the bounds will have positive *width*
877 and *height*; *x0* and *y0* will be the minimal values.
878
879 Parameters
880 ----------
881 path : `~matplotlib.path.Path`
882 ignore : bool, optional
883 - When ``True``, ignore the existing bounds of the `Bbox`.
884 - When ``False``, include the existing bounds of the `Bbox`.
885 - When ``None``, use the last value passed to :meth:`ignore`.
886 updatex, updatey : bool, default: True
887 When ``True``, update the x/y values.
888 """
889 if ignore is None:
890 ignore = self._ignore
891
892 if path.vertices.size == 0 or not (updatex or updatey):
893 return
894
895 if ignore:
896 points = np.array([[np.inf, np.inf], [-np.inf, -np.inf]])
897 minpos = np.array([np.inf, np.inf])
898 else:
899 points = self._points.copy()
900 minpos = self._minpos.copy()
901
902 valid_points = (np.isfinite(path.vertices[..., 0])
903 & np.isfinite(path.vertices[..., 1]))
904
905 if updatex:
906 x = path.vertices[..., 0][valid_points]
907 minx = np.min(x, initial=np.inf)
908 points[0, 0] = min(points[0, 0], minx)
909 points[1, 0] = max(points[1, 0], np.max(x, initial=-np.inf))
910 if minx > 0: # Fast path for all-positive x values
911 minpos[0] = min(minpos[0], minx)
912 else:
913 minpos[0] = min(minpos[0], np.min(x[x > 0], initial=np.inf))
914 if updatey:
915 y = path.vertices[..., 1][valid_points]
916 miny = np.min(y, initial=np.inf)
917 points[0, 1] = min(points[0, 1], miny)
918 points[1, 1] = max(points[1, 1], np.max(y, initial=-np.inf))
919 if miny > 0: # Fast path for all-positive y values
920 minpos[1] = min(minpos[1], miny)
921 else:
922 minpos[1] = min(minpos[1], np.min(y[y > 0], initial=np.inf))
923
924 if np.any(points != self._points) or np.any(minpos != self._minpos):
925 self.invalidate()
926 if updatex:
927 self._points[:, 0] = points[:, 0]
928 self._minpos[0] = minpos[0]
929 if updatey:
930 self._points[:, 1] = points[:, 1]

Callers 3

update_from_data_xyMethod · 0.95
get_pointsMethod · 0.80
_update_line_limitsMethod · 0.80

Calls 4

invalidateMethod · 0.95
minMethod · 0.80
maxMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected