-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
plot_wireframe plotting speedup #29399
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
Merged
scottshambaugh
merged 6 commits into
matplotlib:main
from
scottshambaugh:plot_wireframe_speedup
Jan 8, 2025
Merged
plot_wireframe plotting speedup #29399
scottshambaugh
merged 6 commits into
matplotlib:main
from
scottshambaugh:plot_wireframe_speedup
Jan 8, 2025
Conversation
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
3b832d3
to
8cc938d
Compare
…s.update_from_data_y tweak
ea4a0dc
to
dfe72ed
Compare
dfe72ed
to
703ef23
Compare
703ef23
to
cb0a07c
Compare
greglucas
reviewed
Jan 7, 2025
ff7a2db
to
28d03bf
Compare
greglucas
reviewed
Jan 7, 2025
greglucas
approved these changes
Jan 7, 2025
timhoffm
reviewed
Jan 8, 2025
74543da
to
00062a6
Compare
timhoffm
approved these changes
Jan 8, 2025
CI failures are unrelated, merging |
2 tasks
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR summary
For large wireframe plots (in my testing, 8000x8000), a large chunk of time is spent doing autoscaling of the axes. There is some opportunity to vectorize these calculations and get speedups.
Changes here:
transforms.update_from_data_x
andtransforms.update_from_data_y
axes3d.plot_wireframe
. This also stores the data as a numpy array, which gives speedups when drawing.The compiled function
update_path_extents
is actually just about equal with a vectorized numpy approach speedwise when updating both x and y limits. But when doing single axis limits, it needs to check for NaNs for each pair of x or y, so the numpy approach lets you skip the extra x or y calculations and comes out ahead. This bit is a benefit for all 3D functions, not justplot_wireframe
. I spent some time trying to refactor the compiled function to operate on just a single axis, but it's tricky to disentangle x and y. The numpy approach was easier and just as fast.For my test case I'm seeing an average over 5 runs on main of 6.82 seconds, and on this PR 4.00 seconds - a 1.7x speedup.
Plotting and drawing on main (avg 6.82 sec):

Plotting and drawing on this PR (avg 4.00 sec):

PR checklist