I have build a notebook for visualization purposes.
First, I have exported it to html using the command line interface of nbconvert:
jupyter nbconvert myNotebook.ipynb --no-input Adding the --no-input flag to hide input cells
The output consists of a single html file with embedded plots. As expected
Secondly, In order to add a table of contents to my report I have also installed the jupyter_contrib_nbextensions package.
I use the Table of Contents (2) package.
However when I export the notebook to HTML with
jupyter nbconvert myNotebook.ipynb --no-input --to html_toc
the plots are now saved in a separate folder
I would like to have them embedded in the html file. Anyone ideas how to fix this?
hereby a simple notebook that can be used to illustrate the problem
#%%
import numpy as np
import matplotlib.pyplot as plt
#%% md
# Linear plot with noise
#%%
x = np.linspace(0, 10, 100)
noise = np.random.randn(len(x))
y1 = 2 * x + noise
plt.plot(x, y1);
#%% md
# Sine plot with noise
#%%
y2 = 5 * np.sin(x) + noise
plt.plot(x, y2);
After a few iterations I came up with the following code:
Bonus points: Embed Markdown images in Markdown inserted using
You'll need to define a custom Preprocessor and register it before calling
exporter.from_filename(...). Custom PreprocessorRegistering new Preprocessor