From df862f474f43bb650206790c1e4cbab5cfe5650a Mon Sep 17 00:00:00 2001 From: Tom Gillam Date: Sat, 3 Aug 2024 12:13:48 +0100 Subject: [PATCH 1/2] Use optimised form to update datalim given a path --- lib/matplotlib/axes/_base.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index a0e588569465..25ac8c4b2c88 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -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) @@ -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): """ From 82afdeb3ba673c3b35d394a82a9f6798f009911b Mon Sep 17 00:00:00 2001 From: Tom Gillam Date: Sat, 3 Aug 2024 12:48:23 +0100 Subject: [PATCH 2/2] Remove extraneous blank line --- lib/matplotlib/axes/_base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 25ac8c4b2c88..7c2d8d9f2f01 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -2445,7 +2445,6 @@ def _update_patch_limits(self, patch): updatex=updatex, updatey=updatey) self.ignore_existing_data_limits = False - def add_table(self, tab): """ Add a `.Table` to the Axes; return the table.