8000 Avoid using Bbox machinery in Path.get_extents. · matplotlib/matplotlib@dddbc41 · GitHub
[go: up one dir, main page]

Skip to content

Commit dddbc41

Browse files
committed
Avoid using Bbox machinery in Path.get_extents.
update_from_data_xy is much slower than needed; we can use plain numpy instead.
1 parent 57c8baa commit dddbc41

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/matplotlib/path.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,13 +588,14 @@ def get_extents(self, transform=None, **kwargs):
588588
from .transforms import Bbox
589589
if transform is not None:
590590
self = transform.transform_path(self)
591-
bbox = Bbox.null()
591+
xys = []
592592
for curve, code in self.iter_bezier(**kwargs):
593593
# places where the derivative is zero can be extrema
594594
_, dzeros = curve.axis_aligned_extrema()
595595
# as can the ends of the curve
596-
bbox.update_from_data_xy(curve([0, *dzeros, 1]), ignore=False)
597-
return bbox
596+
xys.append(curve([0, *dzeros, 1]))
597+
xys = np.concatenate(xys)
598+
return Bbox([xys.min(axis=0), xys.max(axis=0)])
598599

599600
def intersects_path(self, other, filled=True):
600601
"""

0 commit comments

Comments
 (0)
0