How To Create Slideshow From Jupyter Notebook

After you write down your jupyter notebook file content, if you want to show the jupyter notebook content to others like a PPT, you can read this article. In this article it will tell you how to convert a jupyter notebook file to a PPT like presentation html file.

1. Create Original Jupyter Notebook Source File.

  1. First start jupyter notebook in a directory and create a jupyter notebook file ( please refer How To Start Jupyter Notebook In Anaconda Python Virtual Environment ). In this example, the file name is TestSlideShow.ipynb.
    create jupyter notebook file
  2. Click the TestSlideShow.ipynb file link to open and edit it. Then click the View —> Cell Toolbar —> None menu item, then you can input python source code in the jupyter notebook file.
    jupyter notebook - view - cell toolbar - none
  3. Click the menu Insert —> Insert Cell Above / Below to insert a cell line in the jupyter notebook file.
  4. Focus the cell line 1, and select Raw NBConvert item in the cell line type drop down list. And input <h1>How To Create SlideShow From Jupyter Notebook</h1> in the first cell line.
    jupyter notebook - select raw nbconvert
  5. Insert a new cell line under above cell line, and select Code in the cell line type drop down list. And input below python code in it. Then click the Run button to generate the output under the python source code, then you can display the audio control bar in the slideshow later. Refer article How To Display Rich Output Media ( Audio, Video, Image etc) In IPython Jupyter Notebook
    from IPython.display import Audio
    audio = Audio(filename='./test.mp3')

    run jupyter notebook python source code and create output

  6. Insert more cell line after above cell line, and input below python source code to display an online image. To show the image in slideshow later, you should focus the cell line and click Run button to run the cell line source code first.
    from IPython.display import Image
    remote_image = Image(url='')

    run jupyter notebook python source code to show an image

  7. Insert another cell line under above line, and input below soruce code in it, when you run the source code, it will create a slide bar under the source code. Refer article How To Add Interactive Widget ( Slide Bar ) In Jupyter Notebook
    from ipywidgets import interact
    @interact(x=(0, 100))
    def double_number(x):
        print("The double of %d is %d." % (x, x*2))

    run jupyter notebook python source code to show a slide bar

2. Convert Jupyter Notebook File To SlideShow Html File.

After you create above jupyter notebook file, and run the code type cell line to generate the output, then you can convert the jupyter notebook file to a slideshow html file follow below steps.

  1. Click View —> Cell Toolbar —> Slideshow menu item, then it will display a Slide Type drop down list at the end of each cell line.
  2. There are 5 slide types in the drop down list. We will explain each slide type below.
    jupyter notebook slide types
  3. Slide : Home page, switch by pressing the left and right arrow keys.
  4. Sub-Slide : Sub page, switch by pressing the up and down arrow keys.
  5. Fragment : It is hidden at the beginning, and it is displayed after pressing the space bar or arrow keys to achieve dynamic effects.
  6. Skip : Cells not shown in the slide show.
  7. Notes : As the speaker’s memo notes, they are not displayed on the slides.
  8. You can select different slide type for each cell line to see the slide type effect. In this example, i select Slide slide type for each cell line.
  9. Click File —> Save and Checkpoint menu item to save the jupyter note book file.
    jupyter notebook save and checkpoint
  10. Then return to the jupyter notebook file list page. Click New —> Terminal menu item to open a new browser tab and enter command line console.
    open terminal in jupyter notebook file list page
  11. Run below command in the opened terminal console.
    jupyter nbconvert TestSlideShow.ipynb --to slides --post serve
  12. Above command will create a slideshow html file in the jupyter notebook file list, in this example the slideshow file name is TestSlideShow.slides.html.
    jupyter notebook file and slideshow html file list
  13. Click the TestSlideShow.slides.html file link to open the slide show html file, then you can see each cell line by click the arrow keys at the bottom right in the html file.
    jupyter notebook slideshow html file first page
    jupyter notebook slideshow html file second page
READ :   How To Run Python 2 Code In Jupyter Notebook

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.