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

Method get_extents

lib/matplotlib/path.py:626–665  ·  view source on GitHub ↗

Get Bbox of the path. Parameters ---------- transform : `~matplotlib.transforms.Transform`, optional Transform to apply to path before computing extents, if any. **kwargs Forwarded to `.iter_bezier`. Returns -------

(self, transform=None, **kwargs)

Source from the content-addressed store, hash-verified

624 return _path.path_in_path(self, None, path, transform)
625
626 def get_extents(self, transform=None, **kwargs):
627 """
628 Get Bbox of the path.
629
630 Parameters
631 ----------
632 transform : `~matplotlib.transforms.Transform`, optional
633 Transform to apply to path before computing extents, if any.
634 **kwargs
635 Forwarded to `.iter_bezier`.
636
637 Returns
638 -------
639 matplotlib.transforms.Bbox
640 The extents of the path Bbox([[xmin, ymin], [xmax, ymax]])
641 """
642 from .transforms import Bbox
643 if transform is not None:
644 self = transform.transform_path(self)
645 if self.codes is None:
646 xys = self.vertices
647 elif len(np.intersect1d(self.codes, [Path.CURVE3, Path.CURVE4])) == 0:
648 # Optimization for the straight line case.
649 # Instead of iterating through each curve, consider
650 # each line segment's end-points
651 # (recall that STOP and CLOSEPOLY vertices are ignored)
652 xys = self.vertices[np.isin(self.codes,
653 [Path.MOVETO, Path.LINETO])]
654 else:
655 xys = []
656 for curve, code in self.iter_bezier(**kwargs):
657 # places where the derivative is zero can be extrema
658 _, dzeros = curve.axis_aligned_extrema()
659 # as can the ends of the curve
660 xys.append(curve([0, *dzeros, 1]))
661 xys = np.concatenate(xys)
662 if len(xys):
663 return Bbox([xys.min(axis=0), xys.max(axis=0)])
664 else:
665 return Bbox.null()
666
667 def intersects_path(self, other, filled=True):
668 """

Callers 15

test_empty_closed_pathFunction · 0.95
adjust_axes_limMethod · 0.45
_set_mathtext_pathMethod · 0.45
get_tightbboxMethod · 0.45
drawMethod · 0.45
set_contextMethod · 0.45
draw_markersMethod · 0.45
draw_pathMethod · 0.45
markerObjectMethod · 0.45
draw_path_collectionMethod · 0.45

Calls 7

iter_bezierMethod · 0.95
BboxClass · 0.85
axis_aligned_extremaMethod · 0.80
minMethod · 0.80
maxMethod · 0.80
nullMethod · 0.80
transform_pathMethod · 0.45

Tested by 9

test_empty_closed_pathFunction · 0.76
test_range_sliderFunction · 0.36
test_exact_extentsFunction · 0.36
test_label_without_ticksFunction · 0.36
test_broken_barh_alignFunction · 0.36
test_degenerate_polygonFunction · 0.36