ipyvolume

repository·master·Indexed 23 days ago

https://github.com/widgetti/ipyvolume

A 3D plotting library for Python in Jupyter notebooks that uses WebGL and IPython widgets to render volumes, scatter plots, quiver plots, and isosurfaces. Version 0.6.3 supports multi-volume rendering, D3-style animations, lasso mouse selections, and VR rendering for Google Cardboard. It integrates with ipywidgets, bokeh, and bqplot, and provides a comprehensive API for figure control, styling, and exporting visualizations as HTML or screenshots.

Tokens
24.2K
Snippets
86
Records
125
Agent score
84%

What's inside ipyvolume

  1. Overview of ipyvolume capabilities

    master

    ipyvolume is a 3D plotting library for Python in Jupyter notebooks that uses WebGL and IPython widgets.

    Key Features:

    • Volume Rendering: Supports (multi) volume rendering and isosurfaces.
    • Scatter & Quiver Plots: Create scatter plots (up to ~1 million glyphs) and quiver plots (scatter plots with directional arrows).
    • Interactivity: Supports lasso mouse selections.
    • Animation: Supports D3-style animations and time-series sequences by passing lists of arrays to scatter/quiver plot properties.
    • Output Formats: Renders in Jupyter notebooks or can be exported as standalone HTML pages/snippets.
    • VR Support: Can render in stereo for Google Cardboard.
    • Integrations: Works with ipywidgets for GUI controls, and supports selection linking with bokeh and bqplot.
  2. Access ipyvolume plotting functions via the ipyvolume namespace

    master
    While functions are defined in ipyvolume.pylab and ipyvolume.widgets, they are imported into the main ipyvolume namespace for convenience. You can call functions like ipyvolume.scatter() directly instead of using the full ipyvolume.pylab.scatter() path.
  3. Install ipyvolume as a non-admin user

    master

    If you do not have administrative privileges, install ipyvolume using the --user flag and enable the extension for your user profile.

    $ pip install ipyvolume --user
    $ jupyter nbextension enable --py --user ipyvolume
  4. Developer workflow for ipyvolume (Jupyter Notebook)

    master

    When developing ipyvolume, you can use a watch command to automatically recompile TypeScript and rebuild the Webpack bundle whenever source files change. You do not need to restart the notebook server; simply refresh the page to see changes.

    Run the following command in the root directory:

    $ (cd js; npm run watch)

    This process:

    1. Watches for changes in the source code.
    2. Runs the TypeScript compiler to transpile src to lib.
    3. Watches the lib directory and uses Webpack to build ROOT/ipyvolume/static/index.js.
  5. Developer workflow for Jupyter Notebook (classical)

    master

    When developing for the classical Jupyter Notebook, you need to watch the JavaScript source files. Run the following command from the repository root to start the TypeScript compiler and Webpack watcher:

    $ (cd js; npm run watch)

    This process watches the src directory for changes, transpiles TypeScript to the lib directory, and uses Webpack to build ROOT/ipyvolume/static/index.js.

    Note: You do not need to restart the notebook server; nbextensions are picked up after a simple page reload.

  6. Install ipyvolume as a user (not recommended)

    master

    If you must install as a user (without root access) and are not using a virtual environment, use the --user flag. Note that this may affect all your Python environments.

    $ pip install ipyvolume --user
    $ jupyter nbextension enable --py --user ipyvolume
    $ jupyter nbextension enable --py --user widgetsnbextension
  7. Developer installation of ipyvolume

    master

    To install ipyvolume for development purposes, follow these steps to clone the repository, install in editable mode, build the JavaScript components, and register the Jupyter extensions:

    $ git clone https://github.com/maartenbreddels/ipyvolume.git
    $ cd ipyvolume
    $ pip install -e . notebook jupyterlab
    $ (cd js; npm run build)
    $ jupyter nbextension install --py --overwrite --symlink --sys-prefix ipyvolume
    $ jupyter nbextension enable --py --sys-prefix ipyvolume
    # for jupyterlab (>=3.0), symlink share/jupyter/labextensions/bqplot-image-gl
    $ jupyter labextension develop . --overwrite
  8. Install ipyvolume using pip

    master

    Install ipyvolume using pip. It is highly recommended to use conda or virtualenv to avoid polluting your global Python environment. Avoid using the --user flag unless you are certain of the implications for your other Python environments.

    $ pip install ipyvolume
  9. Available ipyvolume examples

    master

    The following example notebooks demonstrate various capabilities of ipyvolume, including volume rendering, mesh visualization, animations, and integrations with other plotting libraries:

    • Scatter plots: examples/scatter
    • Volume rendering: examples/volshow, examples/volume-clipping
    • Mesh visualization: examples/mesh
    • Animations: examples/animation
    • Integrations: examples/bqplot, examples/bokeh
    • Visual controls: examples/scales, examples/lighting, examples/popup, examples/slice
    • Specialized plots: examples/moebius, examples/bars
  10. Install ipyvolume via pip

    master

    To install ipyvolume using pip, use the following command.

    Note: It is highly recommended to use conda or virtualenv to avoid polluting your global Python environment. Avoid using the --user flag unless you are certain of the consequences for your other environments.

    $ pip install ipyvolume