-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Improve autoscaling for high order Bezier curves #19214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Improved autoscaling for bezier curves | ||
-------------------------------------- | ||
Bezier curves are now autoscaled to their extents - previously they were | ||
autoscaled to their ends and control points, which in some cases led to | ||
unnecessarily large limits. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ | |
import matplotlib.image as mimage | ||
import matplotlib.lines as mlines | ||
import matplotlib.patches as mpatches | ||
import matplotlib.path as mpath | ||
from matplotlib.rcsetup import cycler, validate_axisbelow | ||
import matplotlib.spines as mspines | ||
import matplotlib.table as mtable | ||
|
@@ -2375,10 +2374,18 @@ def _update_patch_limits(self, patch): | |
((not patch.get_width()) and (not patch.get_height()))): | ||
return | ||
p = patch.get_path() | ||
vertices = p.vertices if p.codes is None else p.vertices[np.isin( | ||
p.codes, (mpath.Path.CLOSEPOLY, mpath.Path.STOP), invert=True)] | ||
if not vertices.size: | ||
return | ||
# Get all vertices on the path | ||
# Loop through each sement to get extrema for Bezier curve sections | ||
vertices = [] | ||
for curve, code in p.iter_bezier(): | ||
# Get distance along the curve of any extrema | ||
_, dzeros = curve.axis_aligned_extrema() | ||
# Calculate vertcies of start, end and any extrema in between | ||
dstansby marked this conversation as resolved.
Show resolved
Hide resolved
|
||
vertices.append(curve([0, *dzeros, 1])) | ||
|
||
if len(vertices): | ||
vertices = np.row_stack(vertices) | ||
Comment on lines
+2386
to
+2387
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you not want to return here if empty any more? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps? It's a private helper function and doesn't seem to break anything though - I guess we're always passing in input that has some vertices. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's because |
||
|
||
patch_trf = patch.get_transform() | ||
updatex, updatey = patch_trf.contains_branch_seperately(self.transData) | ||
if not (updatex or updatey): | ||
|
Uh oh!
There was an error while loading. Please reload this page.