-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Optimize 3D display #6085
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
Optimize 3D display #6085
Conversation
attn @WeatherGod
You have a lot of test failures: https://travis-ci.org/matplotlib/matplotlib/jobs/112810572
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not guaranteed a non-empty array, hence the initialization of minz with 1e9.
kingjr
commented
May 13, 2016
@AlexandreAbraham any progress on this front?
+1 to this. I still haven't found a good method for plotting 3-D brains w/ points on top of it in python. Making a trisurf is super slow when I have lots of triangles.
Hi,
Yes, I have understood why the tests were failing. I have unfortunately made some assumptions on the format of input data that turned out to be wrong. The optimization is still possible but requires more work. I had no time so far to fix it but I'll give it a try today.
a3bdaf8
to
6315961
Compare
'power cycled' to restart the CI against current master.
Looks like there is a problem in one of the examples
Warning, treated as error:
/home/travis/build/matplotlib/matplotlib/doc/examples/mplot3d/pathpatch3d_demo.rst:8: WARNING: Exception occurred in plotting pathpatch3d_demo
from /home/travis/build/matplotlib/matplotlib/doc/mpl_examples/mplot3d/pathpatch3d_demo.py:
Traceback (most recent call last):
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/sphinxext/plot_directive.py", line 654, in render_figures
figman.canvas.figure.savefig(img.filename(format), dpi=dpi)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/figure.py", line 1666, in savefig
self.canvas.print_figure(*args, **kwargs)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/backend_bases.py", line 2227, in print_figure
**kwargs)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/backends/backend_agg.py", line 517, in print_png
FigureCanvasAgg.draw(self)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/backends/backend_agg.py", line 464, in draw
self.figure.draw(self.renderer)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/artist.py", line 68, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/figure.py", line 1262, in draw
renderer, self, dsu, self.suppressComposite)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/image.py", line 139, in _draw_list_compositing_images
a.draw(renderer)
File "/home/travis/build/matplotlib/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py", line 279, in draw
for patch in self.patches]
File "/home/travis/build/matplotlib/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py", line 279, in <listcomp>
for patch in self.patches]
File "/home/travis/build/matplotlib/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py", line 320, in do_3d_projection
s = np.vstack(self._segments3d, np.ones(self._segments3d.shape[1]))
AttributeError: 'PathPatch3D' object has no attribute '_segments3d'
I guess my point is more "let's not add more public API".
Hi @AlexandreAbraham
I think this is almost ready to be merged. Can you make the new public function private and rebase? The rebase might be quite painful...
If you are too busy with the new job, I can take over your branch :)
mwaskom
commented
Jul 12, 2017
Hi, I ended up here from this paper: https://riojournal.com/articles.php?id=12342
I'd be very interested in using the method in the paper, but I'm finding the speed that it can be accomplished with the current implementation of 3d meshses is a dealbreaker. Is there hope for this PR moving forward?
+1 to this PR moving forward
I think that this is the PR that @GaelVaroquaux mentioned to me earlier this week.
lmk if you want someone to usertest this at the sprint. I can bring some brain surfaces :-)
There are several unaddressed comments from @Kojoley . I am currently working on rebasing this as well. I'll force-push a rebase soon (if github allows me).
doesn't look like github will let me, so, I'll do it the old way and submit a PR against your branch.
hmmph, that won't work, either. @AlexandreAbraham , do you see any option to allow maintainers to push changes to your PR on this page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be marginally better as
self._segments3d_data = np.empty((n_segments, 4))
self._segments3d_data[:,:3] = segments
self._segments3d_data[:,3] = 1
Also, are you sure you mean "quaternion" and not "homogenous coordinate"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this loop is np.split
in some form
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get rid of this colon - it makes the function fail on 1d inputs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storing coordinates in the first axis of the array is kind of unusual (see how np.linalg
and scipy.misc.imread
behave).
Perhaps these should all be xyz[..., 0]
instead of xyz[0]
?
This seems to have attracted lots of interest, but eventually never made it over the hump. @WeatherGod is there still some hope for this, or has its momment passed?
Closing as inactive. The goodies are here for anyone who wants them!
This seems to have attracted lots of interest, but eventually never made it over the hump
Closing as inactive.
If it's closed, what's the mechanism then for contributors to know that this PR is stalled, needs help and can be continued ?
do you see any option to allow maintainers to push changes to your PR on this page?
Should be allowed by Github by default now.
I'll make it a priority this week during SciPy. [in 2017]
Maybe someone might be interested in looking into it during the scipy sprint next week?
If I understand correctly this PR rebased (as of July 2017) can be found in @WeatherGod 's https://github.com/WeatherGod/matplotlib/tree/pr/6085 branch.
This PR was continued in #11577
While printing 3D objects, I noticed that the display was pretty slow. The reason is that matplotlib relies a lot on list of objects instead of using big numpy arrays to fasten 3D projections.
This PR aims at solving part of this problem. I replaced some airthmetic on list of vectors by artihmetic on big matrices. This impacts mainly 3D display.
I work on neuroimaging data. I noticed an approximate 25% speedup optimization on 3D display (depending on the complexity of the figure). Refreshment in interactive plotting is also faster. Example script:
Possible other optimizations:
@agramfort and @juhuntenburg, do you notice significant running time reduction with this PR?