Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use optimised form to update datalim given a path
  • Loading branch information
tpgillam committed Aug 3, 2024
commit df862f474f43bb650206790c1e4cbab5cfe5650a
20 changes: 5 additions & 15 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2429,18 +2429,6 @@ def _update_patch_limits(self, patch):
if (isinstance(patch, mpatches.Rectangle) and
((not patch.get_width()) and (not patch.get_height()))):
return
p = patch.get_path()
# Get all vertices on the path
# Loop through each segment to get extrema for Bezier curve sections
vertices = []
for curve, code in p.iter_bezier(simplify=False):
# Get distance along the curve of any extrema
_, dzeros = curve.axis_aligned_extrema()
# Calculate vertices of start, end and any extrema in between
vertices.append(curve([0, *dzeros, 1]))

if len(vertices):
vertices = np.vstack(vertices)

patch_trf = patch.get_transform()
updatex, updatey = patch_trf.contains_branch_seperately(self.transData)
Expand All @@ -2452,9 +2440,11 @@ def _update_patch_limits(self, patch):
updatex = False
if updatey and patch_trf == self.get_xaxis_transform():
updatey = False
trf_to_data = patch_trf - self.transData
xys = trf_to_data.transform(vertices)
self.update_datalim(xys, updatex=updatex, updatey=updatey)
self.dataLim.update_from_path(patch.get_path(),
self.ignore_existing_data_limits,
updatex=updatex, updatey=updatey)
self.ignore_existing_data_limits = False


def add_table(self, tab):
"""
Expand Down