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:
@@ -1,3 +1,5 @@
|
||||
rem call run_notebooks
|
||||
rem cd ..
|
||||
ipython merge_book.py
|
||||
|
||||
jupyter nbconvert --to latex --template book book.ipynb
|
||||
|
||||
@@ -45,25 +45,25 @@ if __name__ == '__main__':
|
||||
['../04-One-Dimensional-Kalman-Filters.ipynb'])'''
|
||||
|
||||
merge_notebooks(f,
|
||||
['../00-Preface.ipynb',
|
||||
'../01-g-h-filter.ipynb',
|
||||
'../02-Discrete-Bayes.ipynb',
|
||||
'../03-Gaussians.ipynb',
|
||||
'../04-One-Dimensional-Kalman-Filters.ipynb',
|
||||
'../05-Multivariate-Gaussians.ipynb',
|
||||
'../06-Multivariate-Kalman-Filters.ipynb',
|
||||
'../07-Kalman-Filter-Math.ipynb',
|
||||
'../08-Designing-Kalman-Filters.ipynb',
|
||||
'../09-Nonlinear-Filtering.ipynb',
|
||||
'../10-Unscented-Kalman-Filter.ipynb',
|
||||
'../11-Extended-Kalman-Filters.ipynb',
|
||||
'../12-Particle-Filters.ipynb',
|
||||
'../13-Smoothing.ipynb',
|
||||
'../14-Adaptive-Filtering.ipynb',
|
||||
'../Appendix-A-Installation.ipynb',
|
||||
'../Appendix-B-Symbols-and-Notations.ipynb',
|
||||
'../Appendix-D-HInfinity-Filters.ipynb',
|
||||
'../Appendix-E-Ensemble-Kalman-Filters.ipynb'])
|
||||
['./tmp/00-Preface.ipynb',
|
||||
'./tmp/01-g-h-filter.ipynb',
|
||||
'./tmp/02-Discrete-Bayes.ipynb',
|
||||
'./tmp/03-Gaussians.ipynb',
|
||||
'./tmp/04-One-Dimensional-Kalman-Filters.ipynb',
|
||||
'./tmp/05-Multivariate-Gaussians.ipynb',
|
||||
'./tmp/06-Multivariate-Kalman-Filters.ipynb',
|
||||
'./tmp/07-Kalman-Filter-Math.ipynb',
|
||||
'./tmp/08-Designing-Kalman-Filters.ipynb',
|
||||
'./tmp/09-Nonlinear-Filtering.ipynb',
|
||||
'./tmp/10-Unscented-Kalman-Filter.ipynb',
|
||||
'./tmp/11-Extended-Kalman-Filters.ipynb',
|
||||
'./tmp/12-Particle-Filters.ipynb',
|
||||
'./tmp/13-Smoothing.ipynb',
|
||||
'./tmp/14-Adaptive-Filtering.ipynb',
|
||||
'./tmp/Appendix-A-Installation.ipynb',
|
||||
'./tmp/Appendix-B-Symbols-and-Notations.ipynb',
|
||||
'./tmp/Appendix-D-HInfinity-Filters.ipynb',
|
||||
'./tmp/Appendix-E-Ensemble-Kalman-Filters.ipynb'])
|
||||
|
||||
|
||||
#remove text printed for matplotlib charts
|
||||
|
||||
15
pdf/rm_notebook.py
Normal file
15
pdf/rm_notebook.py
Normal 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()
|
||||
10
pdf/run_notebooks.bat
Normal file
10
pdf/run_notebooks.bat
Normal file
@@ -0,0 +1,10 @@
|
||||
mkdir tmp
|
||||
REM copy ..\*.ipynb .\tmp
|
||||
REM copy ..\*.py .\tmp
|
||||
REM cp -r ..\code\ .\tmp\code\
|
||||
|
||||
cd tmp
|
||||
|
||||
REM forfiles /m *.ipynb /c "cmd /c ipython ..\rm_notebook.py @file"
|
||||
REM forfiles /m *.ipynb /c "cmd /c jupyter nbconvert --to notebook --execute @file --output @file"
|
||||
|
||||
Reference in New Issue
Block a user