Creating a Jupyter Notebook presentation is a great way to share your data-rich results. All your plots and results are already in slides. There is no need to copy results between Jupyter Notebook and software for presentation manually. The slideshow is a preferred way to share results with non-technical stakeholders. The code in the slides might scare them. How to hide code in a presentation generated from Jupyter Notebook? We will show you 3 approaches to hiding code in the slides.
nbconvert command line tool can be used to convert Jupyter Notebook to presentation slides. It has an option
--no-input to hide the input code. The command to convert Jupyter Notebook to the presentation:
jupyter nbconvert --to slides --no-input my-notebook.ipynb
The above command will produce a
my-notebook.slides.html file with a
If you would like to serve the presentation locally without the code, use:
jupyter nbconvert --to slides --no-input --post serve my-notebook.ipynb
Installation steps in the virtual environment (added
pip install hide_code jupyter nbextension install --py --user hide_code jupyter nbextension enable --py --user hide_code jupyter serverextension enable --py --user hide_code
Please switch on the
Hide code extension in the cell by clicking
Hide Code. Each cell will have a toolbar where you can click a checkbox to show or not a cell in the output notebook.
hide_code extension can be used with a
nbconvert tool with a
hide_code_slides argument passed:
jupyter nbconvert --to hide_code_slides my-notebook.ipynb
Hide code in Mercury
Mercury open-source framework can be used to create parameterized presentations. It uses the YAML header to add interactive widgets to the notebook. There is a
show-code parameter, which decides about displaying the code.
The example YAML header:
--- title: Parametrized Presentation 📊 description: Presentation with widgets output: slides show-code: False # the rest of parameters ... ---
The YAML header is added in the first cell of the notebook. The Mercury serves the notebook as a web application. The output can be a web application, dashboard, report, or presentation.
An example of the parameterized presentation created with Jupyter Notebook and Mercury:
Not everyone is a code lover. Developers using Jupyter Notebook to create slides need to hide the code in the presentation. Slides with hidden code don’t scare non-technical users and still have all plots and results. The Jupyter Notebook with code and results can be committed to a code repository, where tech-savvy users can view them.
Join our newsletter
Subscribe to our newsletter to receive product updates