Skip to content
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

scenes in Jupyter notebook are interleaved #452

Closed
thoth291 opened this issue Oct 26, 2016 · 10 comments
Closed

scenes in Jupyter notebook are interleaved #452

thoth291 opened this issue Oct 26, 2016 · 10 comments

Comments

@thoth291
Copy link

thoth291 commented Oct 26, 2016

When I plot one scene after another in my jupyter notebook with with x3d backend - this happens:
screen shot 2016-10-26 at 14 29 14

What should I do in order to prevent this? (I assume that you see the mesh from Out[2] in the center of the mesh in Out[8])

P.S. May be that's important - I'm running my jupyter notebook server on the remote machine under VirtualGL.

@GaelVaroquaux
Copy link
Contributor

have you tried creating a new figure in the new cell?

@thoth291
Copy link
Author

I did this mlab.clf() in-between and it helped - no more interleaving.
Thanks @GaelVaroquaux !

Is it a bug or it's a feature? So should I clear the figure in all my scripts now?

@prabhuramachandran
Copy link
Member

@thoth291 -- This is the same as what you'd see without the notebook. mlab will not clear the screen automatically and you must do it yourself. BTW, I am curious about your setup with VirtualGL. What hardware are you using and how did you setup VirtualGL on a remote machine? This would be useful to others as well and perhaps we can add this to our documentation if you could share the details.

@prabhuramachandran
Copy link
Member

Am closing this issue for now as this is not an issue but how mlab works.

@thoth291
Copy link
Author

Unfortunately I'm not the one who did the setup.
All what I can say is that we are using HPC Intel machines with 60 cores, plenty of RAM and good GPU on board. We have multiple vnc servers running there. We user tigervnc and wen we start a server we set it up with VirtualGL backend. While you are in vnc client - you need to use a custom script to run you apps to intercept OpenGL and replace it with VirtualGL. In my case that script called vnc3d and I run it like this:

vnc3d jupyter notebook

This setup works perfectly for us and the only thing which is annoying is that you have to keep remember to prepend this vnc3d script to your command each time you deal with OpenGL...

@thoth291
Copy link
Author

@prabhuramachandran , I think this is counter intuitive for Jupyter users. Or at least it should be documented explicitly that one need to do it (mlab.clf()) to ensure correct rendering. None of the 3D engines (for Jupyter) I'm aware of having this kind of problem.

@GaelVaroquaux
Copy link
Contributor

GaelVaroquaux commented Oct 27, 2016 via email

@prabhuramachandran
Copy link
Member

@thoth291 -- thanks for the information on the VirtualGL setup. That looks very interesting and useful. As regards the mlab.clf(), I am happy to document this although I am not sure it is confusing behavior. This is really quite similar to using mlab commands and then using mlab.savefig. You'd have the same effect. Perhaps what is confusing is that this is atypical from the perspective of notebook usage where users do plt.plot() in one cell and do not have to clf() before the next cell. What I can do is to automatically call mlab.clf() after the scene is converted to a PNG or X3D output cell? Would that help?

@thoth291
Copy link
Author

Yeah, that's the confusing part. May be it worth to put a new argument to init_notebook call when user can define what to do. I can imagine that many mlab users would be just fine having figures interleaving (so that they can gradually build a scene) - but the default behavior should be to have independent figures for each cell.

@flothesof
Copy link

Hi all,

sorry for adding things to this closed issue but I thought this would be a good opportunity to give some feedback to the project.
I've just tested the jupyter notebook integration using x3d and got it to work after a few hiccups.
And I've felt the same than @thoth291 : I expected mayavi to create a new figure for a new cell implicitly. I guess I expected this because this is the default for matplotlib using the %matplotlib inline backend.
However, you could also argue for the opposite case: when using the %matplotlib notebook backend, one has to create figures explicitly (if not, the drawing action is perform with the previously opened figure, which sometimes yields surprising results for the user).

So to recap: different matplotlib backends behave differently with respect to new figure creation. From a user's point of view, it would easier if figures were tied to cells. However, if one follows the %matplotlib notebook suggestion, one could follow this workflow:

fig = mlab.figure() # create new figure
s = mlab.test_triangular_mesh() # draw something on it
fig # display figure

This actually works, so maybe something worthwhile would be to reformat the example notebook with this way of working, as well as the tips and tricks section which documents jupyter notebooks (http://docs.enthought.com/mayavi/mayavi/tips.html).

At any rate, I would like to add that I think it's great that this backend exists. Thank you for the hard work @prabhuramachandran @GaelVaroquaux !

Best regards,
Florian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants