Typically, I use Jupyter notebook to make documentation of numerical math in my projects on github. I consider writing python code which generates figures on-the-fly as very economical way how to store figures. Also git can version-control the python code much more efficiently than binary data of rendered figures.
# initialize environment
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import sympy as sy
x = np.linspace(0.0,10.0,1000)
dx = x[1]-x[0]
# some markdown doc
# then plot figures
a = (1.0-x**2)
b = (x-2)**2
plt.plot(x,a,label='a')
plt.plot(x,b,label='b')
plt.plot(x,a*b,lw=2,c='k',label='c')
vmax=1.00; plt.ylim(-vmax,vmax); plt.xlim(0.0,4.0); plt.grid(); plt.legend()
Now I realized that *.ipynb
files which I pushed to github contains huge strings encoding rendered figures as images like this:
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiUAAAFkCAYAAAD....
I would like to force Jupyter not to do that.
EDIT:
as mentioned in comments underneath there are two ways:
- In web GUI got to
Cell > All Output > Clear
, then save - Or use simple python script to do the same
but the problem is that neither of this method is automatic, so it is very easy to forgot and commit to git notebook including the images. It would be very helpfull to have an option to save just striped version of the notebook automatically.