/sphinx_k3d_screenshot

A Sphinx extension to generate and include a screenshot of a K3D Jupyter plot into a documentation

Primary LanguagePythonMIT LicenseMIT

sphinx_k3d_screenshot

PyPI version Conda (channel only) Documentation Status

A Sphinx directive for including the screenshot of a K3D Jupyter plot into a Sphinx document.

This package is based on matplotlib's plot directive.

Install

pip install sphinx_k3d_screenshot

or:

conda install -c davide_sd sphinx_k3d_screenshot 

Take a look at the Installation page to understand how to configure the extension to run on readthedocs.org server.

Usage

.. k3d-screenshot::

   f = lambda r, d: 5 * np.cos(r) * np.exp(-r * d)
   x, y = np.mgrid[-7:7:100j, -7:7:100j]
   r = np.sqrt(x**2 + y**2)
   z = f(r, 0.1)

   fig = k3d.plot()
   surface = surface = k3d.surface(
      z.astype(np.float32), bounds=[-7, 7, -7, 7],
      attribute=z.astype(np.float32),
      color_map=k3d.colormaps.matplotlib_color_maps.viridis)
   fig += surface

   fig

Take a look at the Examples page to visualize the available customization options.