@@ -587,38 +587,26 @@ def contains_path(self, path, transform=None):
587587 transform = transform .frozen ()
588588 return _path .path_in_path (self , None , path , transform )
589589
590- def get_extents (self , transform = None ):
591- """
592- Return the extents (*xmin*, *ymin*, *xmax*, *ymax*) of the path.
593-
594- Unlike computing the extents on the *vertices* alone, this
595- algorithm will take into account the curves and deal with
596- control points appropriately.
597- """
598- from .transforms import Bbox
599- path = self
600- if transform is not None :
601- transform = transform .frozen ()
602- if not transform .is_affine :
603- path = self .transformed (transform )
604- transform = None
605- return Bbox (_path .get_path_extents (path , transform ))
606-
607- def get_exact_extents (self , ** kwargs ):
590+ def get_extents (self , transform = None , ** kwargs ):
608591 """Get size of Bbox of curve (instead of Bbox of control points).
609592
610593 Parameters
611594 ----------
595+ transform : matplotlib.transforms.Transform, optional
596+ Transform to apply to path before computing extents, if any.
612597 kwargs : Dict[str, object]
613598 Forwarded to self.iter_bezier.
614599
615600 Returns
616601 -------
617- extents : (4,) float, array_like
618- The extents of the path ( xmin, ymin, xmax, ymax).
602+ bbox : matplotlib.transforms.Bbox
603+ The extents of the path Bbox([[ xmin, ymin], [ xmax, ymax]])
619604 """
605+ from .transforms import Bbox
606+ if transform is not None :
607+ self = transform .transform_path (self )
620608 maxi = 2 # [xmin, ymin, *xmax, ymax]
621- # return value for empty paths to match _path.h
609+ # return value for empty paths to match what used to be done in _path.h
622610 extents = np .array ([np .inf , np .inf , - np .inf , - np .inf ])
623611 for curve , code in self .iter_bezier (** kwargs ):
624612 # start and endpoints can be extrema of the curve
@@ -628,10 +616,10 @@ def get_exact_extents(self, **kwargs):
628616 _ , dzeros = curve .axis_aligned_extrema
629617 if len (dzeros ) == 0 :
630618 continue
631- for zero in dzeros :
632- potential_extrema = curve .point_at_t (zero )
619+ for ti in dzeros :
620+ potential_extrema = curve .point_at_t (ti )
633621 _update_extents (extents , potential_extrema )
634- return extents
622+ return Bbox . from_extents ( extents )
635623
636624 def intersects_path (self , other , filled = True ):
637625 """
0 commit comments