PERF: 3d draw speedups - #30994
Draft
scottshambaugh wants to merge 11 commits into
Draft
Conversation
scottshambaugh
force-pushed
the
3d_draw_speed
branch
from
January 19, 2026 04:02
25cb60c to
a00c89e
Compare
scottshambaugh
force-pushed
the
3d_draw_speed
branch
from
January 19, 2026 04:04
a00c89e to
077005f
Compare
scottshambaugh
force-pushed
the
3d_draw_speed
branch
from
January 19, 2026 04:13
4f6b42c to
9cee271
Compare
scottshambaugh
force-pushed
the
3d_draw_speed
branch
3 times, most recently
from
January 21, 2026 22:35
e067442 to
54fdb74
Compare
Contributor
Author
|
Note to self: Update to use and match cache pattern in #31012 once that hits |
Contributor
Author
|
TODO: import numpy as np
import matplotlib.pyplot as plt
def main():
rng = np.random.default_rng(42)
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
for _ in range(200):
x = rng.random(25)
y = rng.random(25)
z = rng.random(25)
ax.scatter(x, y, z, s=20)
for _ in range(20):
fig.canvas.draw()
plt.close(fig) |
scottshambaugh
force-pushed
the
3d_draw_speed
branch
from
March 4, 2026 22:49
e3e8845 to
8e94058
Compare
scottshambaugh
force-pushed
the
3d_draw_speed
branch
from
March 8, 2026 20:46
8e94058 to
0f52b37
Compare
scottshambaugh
force-pushed
the
3d_draw_speed
branch
from
March 8, 2026 20:58
0f52b37 to
856183d
Compare
Contributor
Author
|
Waiting on #31012 as a dependency |
1 task
Contributor
Author
|
TODO: small opt here: #31750 (comment) |
scottshambaugh
force-pushed
the
3d_draw_speed
branch
from
May 27, 2026 16:30
856183d to
26b3d25
Compare
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
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
A collection of speedups for 3d plotting, from playing around with the py-spy profiler today.
Waiting on #30980 as a dependency. Diff to that is here:
https://github.com/matplotlib/matplotlib/compare/4ab0014840c3e86b3ca820dba7531857cb168ed6..scottshambaugh:3d_draw_speed
I measure a 40% speedup in our non-agg-rendering code from these changes, which results in a 20% speedup in total runtime for my test script.
Summary of changes:
_get_coord_infofromaxis3dtoaxes3d, since there's nothing axis-specific in itaxes3dcalculations that are used multiple times per draw by each axis:scaled_limits,bounds,transformed_cube, andcoord_info.axis._update_ticks()once per axis at start of draw, instead of multiple times in methodsBefore:

After (less time spent in things that aren't

drawordraw_text:Test script:
PR checklist