8000 Use path extents to get path autoscale limits · matplotlib/matplotlib@faf5bb2 · GitHub
[go: up one dir, main page]

Skip to content

Commit faf5bb2

Browse files
committed
Use path extents to get path autoscale limits
1 parent 8fda099 commit faf5bb2

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,19 +2357,28 @@ def _update_patch_limits(self, patch):
23572357
((not patch.get_width()) and (not patch.get_height()))):
23582358
return
23592359
p = patch.get_path()
2360-
vertices = p.vertices if p.codes is None else p.vertices[np.isin(
2361-
p.codes, (mpath.Path.CLOSEPOLY, mpath.Path.STOP), invert=True)]
2362-
if vertices.size > 0:
2363-
xys = patch.get_patch_transform().transform(vertices)
2364-
if patch.get_data_transform() != self.transData:
2365-
patch_to_data = (patch.get_data_transform() -
2366-
self.transData)
2367-
xys = patch_to_data.transform(xys)
2368-
2369-
updatex, updatey = patch.get_transform().\
2370-
contains_branch_seperately(self.transData)
2371-
self.update_datalim(xys, updatex=updatex,
2372-
updatey=updatey)
2360+
# Get all vertices on the path
2361+
# Loop through each sement to get extrema (as opposed to control points)
2362+
# for Bezier curve sections
2363+
vertices = []
2364+
for curve, code in p.iter_bezier():
2365+
_, dzeros = curve.axis_aligned_extrema()
2366+
# as can the ends of the curve
2367+
vertices.append(curve([0, *dzeros, 1]))
2368+
2369+
if len(vertices):
2370+
vertices = np.row_stack(vertices)
2371+
2372+
xys = patch.get_patch_transform().transform(vertices)
2373+
if patch.get_data_transform() != self.transData:
2374+
patch_to_data = (patch.get_data_transform() -
2375+
self.transData)
2376+
xys = patch_to_data.transform(xys)
2377+
2378+
updatex, updatey = patch.get_transform().\
2379+
contains_branch_seperately(self.transData)
2380+
self.update_datalim(xys, updatex=updatex,
2381+
updatey=updatey)
23732382

23742383
def add_table(self, tab):
23752384
"""

0 commit comments

Comments
 (0)
0