I'm searching for most convenient way how to insert 3D graphics into ipython (Jupyter) notebook? I mean some simple 3D model of machines (space-crafts in my case) mostly composed of simple primitives e.g. like CAD

What I want:

  • people who read the notebook can interactively rotate the model
  • The model is either loaded from file, or directly generated from python (or other) source code
  • The model can be easily composed from simple primitives (lines, cones, cylinders, sphere ... ) within the code
  • something which does not need some non-standard and hard-to-install dependecies, so anybody can easily run the notebook on this computer

Possible solution I found up to now (and problems):

  • FreeCAD IPython integration (just proposal, does not seem to be finished)
  • three.js - but I have no experience with neither Javascript nor it's integration into IPython, so I would prefer some python solution
    • seen.js seems to be exactly what I want, but again it is javascript
  • Plot.ly - it is for data-visualization, rather than for visualization of 3D models
  • PyOpenGL - a bit too low-level, and I'm not sure how well it runs in web browser and Jupyter - I did not found any example
  • POVray - is not interactive, integration to IPython would be cumbersome (calling external render, and than loading resulting image)

I would recommend using PyVista with itkwidgets.

Check the following example.

import pyvista
from pyvista import examples
from itkwidgets import view
dataset = examples.load_uniform()
view(dataset, slicing_planes=True, ui_collapsed=True, shadow=False)

That gives you the following result.

enter image description here

  • OK, this seams very good for 3D data plots. But if I want to visualize something else - e.g. polygon mesh (something like p3d.in ) ? – Prokop Hapala Sep 11 '19 at 17:37
  • @ProkopHapala It is straightforward since it uses VTK. – nicoguaro Sep 11 '19 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.