Notebooks

Overview

A convenient way to share sets of plots and related commentary is to publish a notebook. There are a couple of straightforward ways to create HTML documents from notebooks (Quarto and nbconvert), and then these documents can in turn be printed to PDF if required.

You can also share a live version of a notebook that supports filtering and plot interactions by pubishing it on a platform like Google Colab.

Quarto

The Quarto publishing system can also convert notebooks to HTML. To install the quarto-cli Python package:

pip install quarto-cli

Then, convert any notebook which includes Inspect Viz plots as follows:

quarto render notebook.ipynb --to html --execute

This will create an HTML file named “notebook.html” and a directory named “notebook_files” alongside the “notebook.ipynb”.

Important

The --execute flag is required to ensure that all Inspect Viz outputs are properly rendered (as some notebook front ends like VS Code don’t properly cache Jupyter Widget outputs).

Preview

To work on a notebook with a live updating preview, use the quarto preview command:

quarto preview notebook.ipynb --to html --execute

Code Blocks

You can also specify that you’d to disable display of code blocks using the -M echo:false option:

quarto render notebook.ipynb --to html --execute -M echo:false

If you need a PDF version of the notebook, open the file in a browser and print to PDF.

Publishing

You can use the Quarto Publish command to publish a notebook to GitHub Pages, Hugging Face Spaces, Netlify, or Quarto’s own publishing service.

To publish a notebook, pass it to the quarto publish command:

quarto publish notebook.ipynb

nbconvert

The nbconvert Python package enables export of any Jupyter notebook to HTML. Install nbconvert with:

pip install nbconvert

Then, convert any notebook which includes Inspect Viz plots as follows:

jupyter nbconvert --to html --execute notebook.ipynb

This will create an HTML file named “notebook.html” alongside the “notebook.ipynb”.

Important

The --execute flag is required to ensure that all Inspect Viz outputs are properly rendered (as some notebook front ends like VS Code don’t properly cache Jupyter Widget outputs).

Code Cells

You can also specify that you’d like code cells removed using the --no-input option:

jupyter nbconvert --to html --execute --no-input notebook.ipynb

If you need a PDF version of the notebook, open the file in a browser and print to PDF.