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:
@@ -17,7 +17,6 @@ from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
import code.book_plots as bp
|
||||
from code.book_plots import interactive_plot
|
||||
import filterpy.stats as stats
|
||||
from filterpy.stats import plot_covariance_ellipse
|
||||
from matplotlib.patches import Ellipse
|
||||
@@ -420,37 +419,36 @@ def plot_track(ps, actual, zs, cov, std_scale=1,
|
||||
xlabel='time', ylabel='position',
|
||||
title='Kalman Filter'):
|
||||
|
||||
with interactive_plot():
|
||||
count = len(zs)
|
||||
zs = np.asarray(zs)
|
||||
count = len(zs)
|
||||
zs = np.asarray(zs)
|
||||
|
||||
cov = np.asarray(cov)
|
||||
std = std_scale*np.sqrt(cov[:,0,0])
|
||||
std_top = np.minimum(actual+std, [count + 10])
|
||||
std_btm = np.maximum(actual-std, [-50])
|
||||
cov = np.asarray(cov)
|
||||
std = std_scale*np.sqrt(cov[:,0,0])
|
||||
std_top = np.minimum(actual+std, [count + 10])
|
||||
std_btm = np.maximum(actual-std, [-50])
|
||||
|
||||
std_top = actual + std
|
||||
std_btm = actual - std
|
||||
std_top = actual + std
|
||||
std_btm = actual - std
|
||||
|
||||
bp.plot_track(actual,c='k')
|
||||
bp.plot_measurements(range(1, count + 1), zs)
|
||||
bp.plot_filter(range(1, count + 1), ps)
|
||||
bp.plot_track(actual,c='k')
|
||||
bp.plot_measurements(range(1, count + 1), zs)
|
||||
bp.plot_filter(range(1, count + 1), ps)
|
||||
|
||||
plt.plot(std_top, linestyle=':', color='k', lw=1, alpha=0.4)
|
||||
plt.plot(std_btm, linestyle=':', color='k', lw=1, alpha=0.4)
|
||||
plt.fill_between(range(len(std_top)), std_top, std_btm,
|
||||
facecolor='yellow', alpha=0.2, interpolate=True)
|
||||
plt.legend(loc=4)
|
||||
plt.xlabel(xlabel)
|
||||
plt.ylabel(ylabel)
|
||||
if y_lim is not None:
|
||||
plt.ylim(y_lim)
|
||||
else:
|
||||
plt.ylim((-50, count + 10))
|
||||
plt.plot(std_top, linestyle=':', color='k', lw=1, alpha=0.4)
|
||||
plt.plot(std_btm, linestyle=':', color='k', lw=1, alpha=0.4)
|
||||
plt.fill_between(range(len(std_top)), std_top, std_btm,
|
||||
facecolor='yellow', alpha=0.2, interpolate=True)
|
||||
plt.legend(loc=4)
|
||||
plt.xlabel(xlabel)
|
||||
plt.ylabel(ylabel)
|
||||
if y_lim is not None:
|
||||
plt.ylim(y_lim)
|
||||
else:
|
||||
plt.ylim((-50, count + 10))
|
||||
|
||||
plt.xlim((0,count))
|
||||
plt.title(title)
|
||||
plt.show()
|
||||
plt.xlim((0,count))
|
||||
plt.title(title)
|
||||
plt.show()
|
||||
|
||||
if plot_P:
|
||||
ax = plt.subplot(121)
|
||||
|
||||
Reference in New Issue
Block a user