FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Optimise `Axes.add_patch` to avoid python iteration over bezier segments by tpgillam · Pull Request #28657 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
19 changes: 4 additions & 15 deletions lib/matplotlib/axes/_base.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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,10 @@ 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

Back | FazBrowse Home | New Git URL