Skip to main content
Chemistry LibreTexts Using ipyvolume for 3D plotting

  • Page ID
  • The ipyvolume package for Python allows for 3d plotting straight in LibreTexts code blocks.

    A quick example, taken from the ipyvolume docs, showcases ipyvolume's ability to render three-dimensional objects with sliders to adjust attributes in real time.

    Because ipyvolume isn't included by default, we need to install it via pip at the top of the code block.

    !pip install ipyvolume -q
    import numpy as np
    import ipyvolume as ipv
    V = np.zeros((128,128,128)) # our 3d array
    # outer box
    V[30:-30,30:-30,30:-30] = 0.75
    V[35:-35,35:-35,35:-35] = 0.0
    # inner box
    V[50:-50,50:-50,50:-50] = 0.25
    V[55:-55,55:-55,55:-55] = 0.0
    ipv.quickvolshow(V, level=[0.25, 0.75], opacity=0.03, level_width=0.1, data_min=0, data_max=1)


    • Was this article helpful?