Disable interactive plots for PDF.

nbconvert cannot output interactive plots to PDF. I wrote code
to remove all of the %matplotlib notebook magic, rerun the notebooks,
and then create the PDF.
This commit is contained in:
Roger Labbe
2017-01-14 13:15:24 -08:00
parent e2405b23d5
commit 8463014958
12 changed files with 1234 additions and 1869 deletions

15
pdf/rm_notebook.py Normal file
View File

@@ -0,0 +1,15 @@
import os, sys
print(sys.argv[1])
infile = open(sys.argv[1], encoding="utf8")
data = infile.read()
infile.close()
outfile = open(sys.argv[1], "w", encoding="utf8")
data = data.replace("%matplotlib notebook", "#%matplotlib notebook")
data = data.replace("%matplotlib inline #reset", "#%matplotlib inline #reset")
data = data.replace("time.sleep", "#time.sleep")
data = data.replace("fig.canvas.draw", "#fig.canvas.draw")
data = data.replace("plt.gcf().canvas.draw", "#plt.gcf().canvas.draw")
outfile.write(data)
outfile.close()