The base python installation has a file code.py; this causes
problems when trying to import files from the code subdirectory. I also tried to rearange some code so that book_format does not need to be imported if you are not running in a Jupyter Notebook.
This commit is contained in:
parent
3639394a12
commit
3d288d60d6
@ -57,7 +57,7 @@
|
||||
" font-family: 'Source Code Pro', Consolas, monocco, monospace;\n",
|
||||
"}\n",
|
||||
" div.cell{\n",
|
||||
" width: 800px;\n",
|
||||
" //width: 950px;\n",
|
||||
" margin-left: 0% !important;\n",
|
||||
" margin-right: auto;\n",
|
||||
" }\n",
|
||||
@ -71,7 +71,7 @@
|
||||
" //font-family: 'Chivo',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Cardo',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Arvo',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Poppins',verdana,arial,sans-serif; \n",
|
||||
" //font-family: 'Poppins',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Ubuntu',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Fontin',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Raleway',verdana,arial,sans-serif;\n",
|
||||
@ -95,10 +95,10 @@
|
||||
" h1 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
"\t}\n",
|
||||
"\t\n",
|
||||
"\n",
|
||||
" div.input_area {\n",
|
||||
" background: #F6F6F9;\n",
|
||||
" border: 1px solid #586e75; \n",
|
||||
" border: 1px solid #586e75;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .text_cell_render h1 {\n",
|
||||
@ -111,7 +111,7 @@
|
||||
" display: block;\n",
|
||||
" white-space: wrap;\n",
|
||||
" text-align: left;\n",
|
||||
" } \n",
|
||||
" }\n",
|
||||
" h2 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" text-align: left;\n",
|
||||
@ -127,7 +127,7 @@
|
||||
" display: block;\n",
|
||||
" white-space: wrap;\n",
|
||||
" text-align: left;\n",
|
||||
" } \n",
|
||||
" }\n",
|
||||
" h3 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" }\n",
|
||||
@ -194,42 +194,38 @@
|
||||
" margin: 2em;\n",
|
||||
" }\n",
|
||||
" ul li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.5em; \n",
|
||||
" padding-left: 0.5em;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 0.5em;\n",
|
||||
" }\n",
|
||||
" ul li li{\n",
|
||||
" padding-left: 0.2em; \n",
|
||||
" margin-bottom: 0.2em; \n",
|
||||
" margin-top: 0.2em; \n",
|
||||
" padding-left: 0.2em;\n",
|
||||
" margin-bottom: 0.2em;\n",
|
||||
" margin-top: 0.2em;\n",
|
||||
" }\n",
|
||||
" ol{\n",
|
||||
" margin: 2em;\n",
|
||||
" }\n",
|
||||
" ol li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.5em; \n",
|
||||
" padding-left: 0.5em;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 0.5em;\n",
|
||||
" }\n",
|
||||
" ul li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.2em; \n",
|
||||
" padding-left: 0.5em;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 0.2em;\n",
|
||||
" }\n",
|
||||
" a:link{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" a:visited{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" }\n",
|
||||
" a:hover{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" }\n",
|
||||
" a:focus{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" a:active{\n",
|
||||
@ -237,10 +233,10 @@
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" .rendered_html :link {\n",
|
||||
" text-decoration: underline; \n",
|
||||
" text-decoration: underline;\n",
|
||||
" }\n",
|
||||
" .rendered_html :hover {\n",
|
||||
" text-decoration: none; \n",
|
||||
" text-decoration: none;\n",
|
||||
" }\n",
|
||||
" .rendered_html :visited {\n",
|
||||
" text-decoration: none;\n",
|
||||
@ -253,7 +249,7 @@
|
||||
" }\n",
|
||||
" .warning{\n",
|
||||
" color: rgb( 240, 20, 20 )\n",
|
||||
" } \n",
|
||||
" }\n",
|
||||
" hr {\n",
|
||||
" color: #f3f3f3;\n",
|
||||
" background-color: #f3f3f3;\n",
|
||||
@ -581,7 +577,7 @@
|
||||
"metadata": {
|
||||
"anaconda-cloud": {},
|
||||
"kernelspec": {
|
||||
"display_name": "Python [default]",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@ -595,7 +591,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.2"
|
||||
"version": "3.5.1"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
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
@ -59,7 +59,7 @@
|
||||
" font-family: 'Source Code Pro', Consolas, monocco, monospace;\n",
|
||||
"}\n",
|
||||
" div.cell{\n",
|
||||
" width: 850px;\n",
|
||||
" //width: 950px;\n",
|
||||
" margin-left: 0% !important;\n",
|
||||
" margin-right: auto;\n",
|
||||
" }\n",
|
||||
@ -73,7 +73,7 @@
|
||||
" //font-family: 'Chivo',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Cardo',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Arvo',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Poppins',verdana,arial,sans-serif; \n",
|
||||
" //font-family: 'Poppins',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Ubuntu',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Fontin',verdana,arial,sans-serif;\n",
|
||||
" //font-family: 'Raleway',verdana,arial,sans-serif;\n",
|
||||
@ -97,10 +97,10 @@
|
||||
" h1 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
"\t}\n",
|
||||
"\t\n",
|
||||
"\n",
|
||||
" div.input_area {\n",
|
||||
" background: #F6F6F9;\n",
|
||||
" border: 1px solid #586e75; \n",
|
||||
" border: 1px solid #586e75;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .text_cell_render h1 {\n",
|
||||
@ -113,7 +113,7 @@
|
||||
" display: block;\n",
|
||||
" white-space: wrap;\n",
|
||||
" text-align: left;\n",
|
||||
" } \n",
|
||||
" }\n",
|
||||
" h2 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" text-align: left;\n",
|
||||
@ -129,7 +129,7 @@
|
||||
" display: block;\n",
|
||||
" white-space: wrap;\n",
|
||||
" text-align: left;\n",
|
||||
" } \n",
|
||||
" }\n",
|
||||
" h3 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" }\n",
|
||||
@ -196,42 +196,38 @@
|
||||
" margin: 2em;\n",
|
||||
" }\n",
|
||||
" ul li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.5em; \n",
|
||||
" padding-left: 0.5em;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 0.5em;\n",
|
||||
" }\n",
|
||||
" ul li li{\n",
|
||||
" padding-left: 0.2em; \n",
|
||||
" margin-bottom: 0.2em; \n",
|
||||
" margin-top: 0.2em; \n",
|
||||
" padding-left: 0.2em;\n",
|
||||
" margin-bottom: 0.2em;\n",
|
||||
" margin-top: 0.2em;\n",
|
||||
" }\n",
|
||||
" ol{\n",
|
||||
" margin: 2em;\n",
|
||||
" }\n",
|
||||
" ol li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.5em; \n",
|
||||
" padding-left: 0.5em;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 0.5em;\n",
|
||||
" }\n",
|
||||
" ul li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.2em; \n",
|
||||
" padding-left: 0.5em;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 0.2em;\n",
|
||||
" }\n",
|
||||
" a:link{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" a:visited{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" }\n",
|
||||
" a:hover{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" }\n",
|
||||
" a:focus{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" a:active{\n",
|
||||
@ -239,10 +235,10 @@
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" .rendered_html :link {\n",
|
||||
" text-decoration: underline; \n",
|
||||
" text-decoration: underline;\n",
|
||||
" }\n",
|
||||
" .rendered_html :hover {\n",
|
||||
" text-decoration: none; \n",
|
||||
" text-decoration: none;\n",
|
||||
" }\n",
|
||||
" .rendered_html :visited {\n",
|
||||
" text-decoration: none;\n",
|
||||
@ -255,7 +251,7 @@
|
||||
" }\n",
|
||||
" .warning{\n",
|
||||
" color: rgb( 240, 20, 20 )\n",
|
||||
" } \n",
|
||||
" }\n",
|
||||
" hr {\n",
|
||||
" color: #f3f3f3;\n",
|
||||
" background-color: #f3f3f3;\n",
|
||||
@ -496,10 +492,9 @@
|
||||
"$$\\frac{1}{2 \\sqrt{\\phi}}$$"
|
||||
],
|
||||
"text/plain": [
|
||||
" 1 \n",
|
||||
"───────\n",
|
||||
" ___\n",
|
||||
"2⋅╲╱ φ "
|
||||
" 1 \n",
|
||||
"────\n",
|
||||
"2⋅√φ"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
@ -749,7 +744,7 @@
|
||||
"metadata": {
|
||||
"anaconda-cloud": {},
|
||||
"kernelspec": {
|
||||
"display_name": "Python [default]",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -797,7 +797,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import code.book_plots as bp\n",
|
||||
"import kf_book.book_plots as bp\n",
|
||||
"from filterpy.kalman import KalmanFilter\n",
|
||||
"import math\n",
|
||||
"import numpy as np\n",
|
||||
@ -910,7 +910,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import code.ekf_internal as ekf\n",
|
||||
"import kf_book.ekf_internal as ekf\n",
|
||||
"ekf.plot_ball()"
|
||||
]
|
||||
},
|
||||
@ -1042,7 +1042,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.1"
|
||||
"version": "3.5.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
@ -337,7 +337,7 @@
|
||||
"metadata": {
|
||||
"anaconda-cloud": {},
|
||||
"kernelspec": {
|
||||
"display_name": "Python [default]",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
|
@ -17,7 +17,6 @@ from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
from contextlib import contextmanager
|
||||
from distutils.version import LooseVersion
|
||||
from IPython.core.display import HTML
|
||||
import json
|
||||
import matplotlib
|
||||
@ -27,7 +26,7 @@ import numpy as np
|
||||
import os.path
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from kf_book.book_plots import set_figsize, reset_axis
|
||||
|
||||
# version 1.4.3 of matplotlib has a bug that makes
|
||||
# it issue a spurious warning on every plot that
|
||||
@ -60,27 +59,6 @@ pylab.rcParams['figure.max_open_warning'] = 50
|
||||
|
||||
|
||||
|
||||
def equal_axis():
|
||||
pylab.rcParams['figure.figsize'] = 10,10
|
||||
plt.axis('equal')
|
||||
|
||||
|
||||
def reset_axis():
|
||||
pylab.rcParams['figure.figsize'] = 9, 3
|
||||
|
||||
def set_figsize(x=9, y=4):
|
||||
pylab.rcParams['figure.figsize'] = x, y
|
||||
|
||||
|
||||
@contextmanager
|
||||
def figsize(x=9, y=4):
|
||||
"""Temporarily set the figure size using 'with figsize(a,b):'"""
|
||||
|
||||
size = pylab.rcParams['figure.figsize']
|
||||
set_figsize(x, y)
|
||||
yield
|
||||
pylab.rcParams['figure.figsize'] = size
|
||||
|
||||
|
||||
@contextmanager
|
||||
def numpy_precision(precision):
|
||||
@ -123,27 +101,27 @@ def _decode_dict(data):
|
||||
return rv
|
||||
|
||||
|
||||
def load_style(directory = '.', name='code/custom.css'):
|
||||
if sys.version_info[0] >= 3:
|
||||
style = json.load(open(os.path.join(directory, "code/538.json")))
|
||||
else:
|
||||
style = json.load(open(directory + "/code/538.json"), object_hook=_decode_dict)
|
||||
|
||||
# matplotlib has deprecated the use of axes.color_cycle as of version
|
||||
|
||||
try:
|
||||
import seaborneee
|
||||
except:
|
||||
def load_style(directory = '.', name='kf_book/custom.css'):
|
||||
version = [int(version_no) for version_no in matplotlib.__version__.split('.')]
|
||||
if version[0] > 1 or (version[0] == 1 and version[1] >= 5):
|
||||
style["axes.prop_cycle"] = "cycler('color', ['#6d904f','#013afe', '#202020','#fc4f30','#e5ae38','#A60628','#30a2da','#008080','#7A68A6','#CF4457','#188487','#E24A33'])"
|
||||
style.pop("axes.color_cycle", None)
|
||||
plt.rcParams.update(style)
|
||||
set_figsize()
|
||||
reset_axis ()
|
||||
np.set_printoptions(suppress=True,precision=3, linewidth=70,
|
||||
formatter={'float':lambda x:' {:.3}'.format(x)})
|
||||
|
||||
styles = open(os.path.join(directory, name), 'r').read()
|
||||
set_figsize()
|
||||
return HTML(styles)
|
||||
try:
|
||||
if sys.version_info[0] >= 3:
|
||||
style = json.load(open(os.path.join(directory, "kf_book/538.json")))
|
||||
else:
|
||||
style = json.load(open(directory + "/kf_book/538.json"), object_hook=_decode_dict)
|
||||
|
||||
# matplotlib has deprecated the use of axes.color_cycle as of version
|
||||
if version[0] > 1 or (version[0] == 1 and version[1] >= 5):
|
||||
style["axes.prop_cycle"] = "cycler('color', ['#6d904f','#013afe', '#202020','#fc4f30','#e5ae38','#A60628','#30a2da','#008080','#7A68A6','#CF4457','#188487','#E24A33'])"
|
||||
style.pop("axes.color_cycle", None)
|
||||
plt.rcParams.update(style)
|
||||
except:
|
||||
pass
|
||||
set_figsize()
|
||||
reset_axis ()
|
||||
np.set_printoptions(suppress=True,precision=3, linewidth=70,
|
||||
formatter={'float':lambda x:' {:.3}'.format(x)})
|
||||
|
||||
styles = open(os.path.join(directory, name), 'r').read()
|
||||
set_figsize()
|
||||
return HTML(styles)
|
||||
|
@ -16,7 +16,7 @@ for more information.
|
||||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
import code.book_plots as bp
|
||||
import kf_book.book_plots as bp
|
||||
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow, FancyArrow
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
@ -18,9 +18,9 @@ from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
|
||||
from book_format import figsize
|
||||
from contextlib import contextmanager
|
||||
import matplotlib as mpl
|
||||
import matplotlib.pylab as pylab
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.patches import Circle
|
||||
import numpy as np
|
||||
@ -32,10 +32,34 @@ try:
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def equal_axis():
|
||||
pylab.rcParams['figure.figsize'] = 10,10
|
||||
plt.axis('equal')
|
||||
|
||||
|
||||
def reset_axis():
|
||||
pylab.rcParams['figure.figsize'] = 9, 3
|
||||
|
||||
def set_figsize(x=9, y=4):
|
||||
pylab.rcParams['figure.figsize'] = x, y
|
||||
|
||||
|
||||
@contextmanager
|
||||
def figsize(x=9, y=4):
|
||||
"""Temporarily set the figure size using 'with figsize(a,b):'"""
|
||||
|
||||
size = pylab.rcParams['figure.figsize']
|
||||
set_figsize(x, y)
|
||||
yield
|
||||
pylab.rcParams['figure.figsize'] = size
|
||||
|
||||
|
||||
|
||||
""" If the plot is inline (%matplotlib inline) we need to
|
||||
do special processing for the interactive_plot context manager,
|
||||
otherwise it outputs a lot of extra <matplotlib.figure.figure
|
||||
type output into the notebook."""
|
||||
type output into the notebook."""
|
||||
|
||||
IS_INLINE = mpl.get_backend().find('backend_inline') != -1
|
||||
|
||||
@ -50,12 +74,12 @@ def end_interactive(fig):
|
||||
time.sleep(1.)
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
|
||||
@contextmanager
|
||||
def interactive_plot(close=True, fig=None):
|
||||
if fig is None and not IS_INLINE:
|
||||
fig = plt.figure()
|
||||
|
||||
|
||||
yield
|
||||
try:
|
||||
# if the figure only uses annotations tight_output
|
||||
@ -64,7 +88,7 @@ def interactive_plot(close=True, fig=None):
|
||||
except:
|
||||
pass
|
||||
|
||||
if not IS_INLINE:
|
||||
if not IS_INLINE:
|
||||
plt.show()
|
||||
|
||||
if close and not IS_INLINE:
|
@ -16,7 +16,7 @@ for more information.
|
||||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
import code.book_plots as bp
|
||||
import kf_book.book_plots as bp
|
||||
import filterpy.kalman as kf
|
||||
from math import radians, sin, cos, sqrt, exp
|
||||
import matplotlib.pyplot as plt
|
@ -17,7 +17,7 @@ from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
|
||||
import code.book_plots as book_plots
|
||||
import kf_book.book_plots as book_plots
|
||||
import numpy as np
|
||||
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow, FancyArrow
|
||||
import pylab as plt
|
@ -16,7 +16,7 @@ for more information.
|
||||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
import code.book_plots as bp
|
||||
import kf_book.book_plots as bp
|
||||
import filterpy.stats as stats
|
||||
from math import sqrt
|
||||
import matplotlib.pyplot as plt
|
@ -16,13 +16,18 @@ for more information.
|
||||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
import code.book_plots as bp
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
|
||||
try:
|
||||
import kf_book.book_plots as bp
|
||||
except:
|
||||
import book_plots as bp
|
||||
|
||||
import filterpy.stats as stats
|
||||
from filterpy.stats import plot_covariance_ellipse
|
||||
from matplotlib.patches import Ellipse
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib import cm
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
import numpy as np
|
||||
from numpy.random import multivariate_normal
|
||||
|
||||
@ -273,33 +278,44 @@ def plot_3d_covariance(mean, cov):
|
||||
|
||||
xs = np.arange(minx, maxx, (maxx-minx)/40.)
|
||||
ys = np.arange(miny, maxy, (maxy-miny)/40.)
|
||||
xv, yv = np.meshgrid (xs, ys)
|
||||
xv, yv = np.meshgrid(xs, ys)
|
||||
|
||||
zs = np.array([100.* stats.multivariate_gaussian(np.array([x,y]),mean,cov) \
|
||||
for x, y in zip(np.ravel(xv), np.ravel(yv))])
|
||||
zv = zs.reshape(xv.shape)
|
||||
|
||||
maxz = np.max(zs)
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
|
||||
#ax = plt.figure().add_subplot(111, projection='3d')
|
||||
ax = plt.gca(projection='3d')
|
||||
#ax = plt.gca(projection='3d')
|
||||
ax.plot_surface(xv, yv, zv, rstride=1, cstride=1, cmap=cm.autumn)
|
||||
|
||||
ax.set_xlabel('X')
|
||||
ax.set_ylabel('Y')
|
||||
|
||||
|
||||
# For unknown reasons this started failing in Jupyter notebook when
|
||||
# using `%matplotlib inline` magic. Still works fine in IPython or when
|
||||
# `%matplotlib notebook` magic is used.
|
||||
x = mean[0]
|
||||
zs = np.array([100.* stats.multivariate_gaussian(np.array([x, y]),mean,cov)
|
||||
for _, y in zip(np.ravel(xv), np.ravel(yv))])
|
||||
zv = zs.reshape(xv.shape)
|
||||
ax.contour(xv, yv, zv, zdir='x', offset=minx-1, cmap=cm.binary)
|
||||
try:
|
||||
pass
|
||||
#ax.contour(xv, yv, zv, zdir='x', offset=minx-1, cmap=cm.binary)
|
||||
except:
|
||||
pass
|
||||
|
||||
y = mean[1]
|
||||
zs = np.array([100.* stats.multivariate_gaussian(np.array([x, y]),mean,cov)
|
||||
for x, _ in zip(np.ravel(xv), np.ravel(yv))])
|
||||
zv = zs.reshape(xv.shape)
|
||||
ax.contour(xv, yv, zv, zdir='y', offset=maxy, cmap=cm.binary)
|
||||
try:
|
||||
pass
|
||||
#ax.contour(xv, yv, zv, zdir='y', offset=maxy, cmap=cm.binary)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def plot_3d_sampled_covariance(mean, cov):
|
@ -17,16 +17,14 @@ from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
|
||||
from code.book_plots import figsize, end_interactive
|
||||
from kf_book.book_plots import figsize, end_interactive
|
||||
from filterpy.monte_carlo import stratified_resample, residual_resample
|
||||
import matplotlib as mpl
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
import numpy as np
|
||||
from numpy.random import randn, random, uniform, multivariate_normal, seed
|
||||
#from nonlinear_plots import plot_monte_carlo_mean
|
||||
import scipy.stats
|
||||
#from RobotLocalizationParticleFilter import *
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user