Blogging with Jupyter

Dec 25, 2019

I sometimes made charts for fun. While most of them were built with some Python scripts and Jupyer notebooks, I usually just export the PNG images from the notebooks. However this “method” ignores what Jupyter is desinged for: making a notebook which is executable.

So I’ve added nb2hugo on this blog, which converts all Jupyter notebooks to Hugo-friendly Markdown files. My version utilizes Hugo’s Page Bundles to save image files under content/ directory.

import matplotlib
import numpy as np
import matplotlib.pyplot as plt
# It doesn't work nicely since images in Markdown don't have width/height
# %config InlineBackend.figure_format = 'retina'
x = np.linspace(0, 3*np.pi, 500)
plt.plot(x, np.sin(x**2))
[<matplotlib.lines.Line2D at 0x1181f68d0>]