Kalman-and-Bayesian-Filters.../code/adaptive_internal.py

40 lines
963 B
Python
Raw Normal View History

2015-07-01 05:14:39 +02:00
# -*- coding: utf-8 -*-
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
2015-08-01 17:52:48 +02:00
This is licensed under an MIT license. See the LICENSE.txt file
for more information.
2015-07-01 05:14:39 +02:00
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
2015-07-01 05:14:39 +02:00
import book_plots as bp
import matplotlib.pyplot as plt
2015-07-01 05:14:39 +02:00
def plot_track_and_residuals(t, xs, z_xs, res):
plt.subplot(121)
2015-07-31 06:45:13 +02:00
if z_xs is not None:
bp.plot_measurements(t, z_xs, label='z')
2015-07-01 05:14:39 +02:00
bp.plot_filter(t, xs)
plt.legend(loc=2)
plt.xlabel('time (sec)')
plt.ylabel('X')
plt.title('estimates vs measurements')
plt.subplot(122)
# plot twice so it has the same color as the plot to the left!
plt.plot(t, res)
plt.plot(t, res)
plt.xlabel('time (sec)')
plt.ylabel('residual')
plt.title('residuals')
plt.show()