Fixed interactive plots for PDF.

the plots generated by interactive plots (%matplotlib notebook) do
not show up in the PDF. This has meant that I haven't been able to
update the PDF since febuary. I switched the default plotting
mechanism to noninteractive.
This commit is contained in:
Roger Labbe 2016-09-20 06:49:15 -07:00
parent 97f3f64efb
commit 96749eb378
23 changed files with 2930 additions and 199503 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -335,8 +335,9 @@
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},

62
Untitled1.ipynb Normal file

File diff suppressed because one or more lines are too long

View File

@ -28,10 +28,6 @@ import os.path
import sys
import warnings
try:
import seaborn
except:
pass
# version 1.4.3 of matplotlib has a bug that makes
# it issue a spurious warning on every plot that
@ -136,7 +132,7 @@ def load_style(directory = '.', name='code/custom.css'):
# matplotlib has deprecated the use of axes.color_cycle as of version
try:
import seaborn
import seaborneee
except:
version = [int(version_no) for version_no in matplotlib.__version__.split('.')]
if version[0] > 1 or (version[0] == 1 and version[1] >= 5):

View File

@ -22,12 +22,13 @@ from book_format import figsize
from contextlib import contextmanager
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
import numpy as np
import sys
import time
try:
import seaborn
import seabornee
except:
pass
@ -90,7 +91,6 @@ def plot_errorbar1():
plot_errorbars([(160, 8, 'A'), (170, 8, 'B')],
xlims=(145, 185), ylims=(-1, 1))
plt.show()
plt.savefig('../figs/gh_errorbar1.png', pad_inches=0.)
def plot_errorbar2():
@ -98,14 +98,12 @@ def plot_errorbar2():
plt.figure()
plot_errorbars([(160, 3, 'A'), (170, 9, 'B')],
xlims=(145, 185), ylims=(-1, 1))
plt.savefig('../figs/gh_errorbar2.png', pad_inches=0.)
def plot_errorbar3():
with figsize(y=2):
plt.figure()
plot_errorbars([(160, 1, 'A'), (170, 9, 'B')],
xlims=(145, 185), ylims=(-1, 1))
plt.savefig('../figs/gh_errorbar3.png', pad_inches=0.1)
def plot_hypothesis1():
@ -122,7 +120,6 @@ def plot_hypothesis1():
plt.xlabel('day')
plt.ylabel('lbs')
plt.tight_layout()
plt.savefig('../figs/gh_hypothesis1.png', pad_inches=0.1)
def plot_hypothesis2():
@ -134,7 +131,6 @@ def plot_hypothesis2():
plt.xlim(0, 11); plt.ylim(150, 185)
plt.xlabel('day')
plt.ylabel('lbs')
plt.savefig('../figs/gh_hypothesis2.png', pad_inches=0.1)
def plot_hypothesis3():
@ -150,7 +146,6 @@ def plot_hypothesis3():
plt.xlim(0, 13); plt.ylim(145, 185)
plt.xlabel('day')
plt.ylabel('weight (lbs)')
plt.savefig('../figs/gh_hypothesis3.png', pad_inches=0.1)
def plot_hypothesis4():
@ -167,7 +162,6 @@ def plot_hypothesis4():
plt.xlabel('day')
plt.ylabel('weight (lbs)')
show_legend()
plt.savefig('../figs/gh_hypothesis4.png', pad_inches=0.1)
def plot_hypothesis5():
@ -186,7 +180,6 @@ def plot_hypothesis5():
plt.xlabel('day')
plt.ylabel('weight (lbs)')
show_legend()
plt.savefig('../figs/gh_hypothesis5.png', pad_inches=0.1)
def plot_estimate_chart_1():
@ -202,7 +195,6 @@ def plot_estimate_chart_1():
ax.xaxis.grid(True, which="major", linestyle='dotted')
ax.yaxis.grid(True, which="major", linestyle='dotted')
plt.tight_layout()
plt.savefig('../figs/gh_estimate1.png', pad_inches=0.1)
def plot_estimate_chart_2():
@ -222,7 +214,7 @@ def plot_estimate_chart_2():
plt.ylabel('weight (lbs)')
ax.xaxis.grid(True, which="major", linestyle='dotted')
ax.yaxis.grid(True, which="major", linestyle='dotted')
plt.savefig('../figs/gh_estimate2.png', pad_inches=0.1)
def plot_estimate_chart_3():
with figsize(y=2.5):
@ -248,15 +240,13 @@ def plot_estimate_chart_3():
plt.ylabel('weight (lbs)')
ax.xaxis.grid(True, which="major", linestyle='dotted')
ax.yaxis.grid(True, which="major", linestyle='dotted')
plt.savefig('../figs/gh_estimate3.png', pad_inches=0.1)
def create_predict_update_chart(box_bg = '#CCCCCC',
arrow1 = '#88CCFF',
arrow2 = '#88FF88'):
plt.figure(figsize=(4, 2.), facecolor='w')
#plt.figure(figsize=(14,12.5), facecolor='w')
plt.figure(figsize=(4, 3.), facecolor='w')
ax = plt.axes((0, 0, 1, 1),
xticks=[], yticks=[], frameon=False)
@ -316,7 +306,6 @@ def create_predict_update_chart(box_bg = '#CCCCCC',
ha='center', va='center', fontsize=14)
plt.axis('equal')
plt.xlim(2,10)
plt.savefig('../figs/gh_predict_update.png', pad_inches=0.1)
def show_residual_chart(show_eq=True, show_H=False):
@ -359,11 +348,6 @@ def show_residual_chart(show_eq=True, show_H=False):
ax.yaxis.set_label_position("right")
plt.ylabel('state')
plt.xlim(-0.1, 1.5)
if show_H:
plt.savefig('../figs/residual_chart_with_h.png', pad_inches=0.1)
else:
plt.savefig('../figs/residual_chart.png', pad_inches=0.1)
def show_legend():

BIN
pdf/book.synctex.gz Normal file

Binary file not shown.

View File

@ -5,6 +5,19 @@ import sys
from formatting import *
def inplace_change(filename, old_string, new_string):
# Safely read the input filename using 'with'
with open(filename, encoding='utf-8') as f:
s = f.read()
if old_string not in s:
return
# Safely write the changed content, if found in the file
with open(filename, 'w', encoding='utf-8') as f:
s = s.replace(old_string, new_string)
f.write(s)
def merge_notebooks(outfile, filenames):
merged = None
added_appendix = False
@ -27,27 +40,32 @@ def merge_notebooks(outfile, filenames):
if __name__ == '__main__':
f = open('book.ipynb', 'w', encoding='utf-8')
'''merge_notebooks(f,
['../02-Discrete-Bayes.ipynb'])'''
with open('book.ipynb', 'w', encoding='utf-8') as f:
merge_notebooks(f,
['../14-Adaptive-Filtering.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'])
'''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'])'''
#remove text printed for matplotlib charts
inplace_change('book.ipynb', '<IPython.core.display.Javascript object>', '')
inplace_change('book.ipynb', '<IPython.core.display.HTML object>', '')