Changes to condense material.
Lots of small changes to try to get page count down. I'm not liking this.
This commit is contained in:
@@ -72,19 +72,34 @@ def plot_residual_limits(Ps):
|
||||
facecolor='#ffff00', alpha=0.3)
|
||||
|
||||
|
||||
def plot_track(xs, ys=None, label='Track', c='k', lw=2):
|
||||
def plot_track(xs, ys=None, label='Track', c='k', lw=2, **kwargs):
|
||||
if ys is not None:
|
||||
plt.plot(xs, ys, c=c, lw=lw, label=label)
|
||||
plt.plot(xs, ys, c=c, lw=lw, label=label, **kwargs)
|
||||
else:
|
||||
plt.plot(xs, c=c, lw=lw, label=label)
|
||||
plt.plot(xs, c=c, lw=lw, label=label, **kwargs)
|
||||
|
||||
|
||||
#c='#013afe'
|
||||
def plot_filter(xs, ys=None, c='#6d904f', label='Filter', **kwargs):
|
||||
if ys is not None:
|
||||
plt.plot(xs, ys, c=c, label=label, **kwargs)
|
||||
else:
|
||||
plt.plot(xs, c=c, label=label, **kwargs)
|
||||
def plot_filter(xs, ys=None, c='#6d904f', label='Filter', vars=None, **kwargs):
|
||||
|
||||
if ys is None:
|
||||
ys = xs
|
||||
xs = range(len(ys))
|
||||
|
||||
plt.plot(xs, ys, c=c, label=label, **kwargs)
|
||||
|
||||
if vars is None:
|
||||
return
|
||||
vars = np.asarray(vars)
|
||||
|
||||
std = np.sqrt(vars)
|
||||
std_top = ys+std
|
||||
std_btm = ys-std
|
||||
|
||||
plt.plot(xs, ys+std, linestyle=':', c='k', lw=2)
|
||||
plt.plot(xs, ys-std, linestyle=':', c='k', lw=2)
|
||||
plt.fill_between(xs, std_btm, std_top,
|
||||
facecolor='yellow', alpha=0.2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -11,6 +11,22 @@ import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import stats
|
||||
|
||||
def plot_height_std(x, lw=10):
|
||||
m = np.mean(x)
|
||||
s = np.std(x)
|
||||
|
||||
for i, height in enumerate(x):
|
||||
plt.plot([i+1, i+1], [0, height], color='k', lw=lw)
|
||||
plt.xlim(0,len(x)+1)
|
||||
plt.axhline(m-s, ls='--')
|
||||
plt.axhline(m+s, ls='--')
|
||||
plt.fill_between((0, len(x)+1), m-s, m+s,
|
||||
facecolor='yellow', alpha=0.4)
|
||||
plt.xlabel('student')
|
||||
plt.ylabel('height (m)')
|
||||
plt.show()
|
||||
|
||||
|
||||
def plot_gaussian (mu, variance,
|
||||
mu_line=False,
|
||||
xlim=None,
|
||||
@@ -31,8 +47,6 @@ def plot_gaussian (mu, variance,
|
||||
plt.show()
|
||||
|
||||
def display_stddev_plot():
|
||||
figsize = pylab.rcParams['figure.figsize']
|
||||
pylab.rcParams['figure.figsize'] = 12,6
|
||||
xs = np.arange(10,30,0.1)
|
||||
var = 8; stddev = math.sqrt(var)
|
||||
p2, = plt.plot (xs,[stats.gaussian(x, 20, var) for x in xs])
|
||||
|
||||
@@ -6,7 +6,7 @@ import book_plots
|
||||
def create_predict_update_chart(box_bg = '#CCCCCC',
|
||||
arrow1 = '#88CCFF',
|
||||
arrow2 = '#88FF88'):
|
||||
plt.figure(figsize=(6,6), facecolor='w')
|
||||
plt.figure(figsize=(4,4), facecolor='w')
|
||||
ax = plt.axes((0, 0, 1, 1),
|
||||
xticks=[], yticks=[], frameon=False)
|
||||
#ax.set_xlim(0, 10)
|
||||
@@ -187,13 +187,12 @@ def plot_hypothesis5():
|
||||
plt.show()
|
||||
|
||||
def plot_g_h_results(measurements, filtered_data,
|
||||
title='', z_label='Scale', ):
|
||||
title='', z_label='Measurements', **kwargs):
|
||||
book_plots.plot_filter(filtered_data, **kwargs)
|
||||
book_plots.plot_measurements(measurements, label=z_label)
|
||||
book_plots.plot_filter(filtered_data)
|
||||
book_plots.show_legend()
|
||||
plt.title(title)
|
||||
plt.gca().set_xlim(left=0,right=len(measurements))
|
||||
plt.show()
|
||||
|
||||
if __name__ == '__main__':
|
||||
create_predict_update_chart()
|
||||
@@ -157,6 +157,7 @@ def multivariate_gaussian(x, mu, cov):
|
||||
def plot_gaussian(mean, variance,
|
||||
mean_line=False,
|
||||
xlim=None,
|
||||
ylim=None,
|
||||
xlabel=None,
|
||||
ylabel=None):
|
||||
""" plots the normal distribution with the given mean and variance. x-axis
|
||||
@@ -182,6 +183,9 @@ def plot_gaussian(mean, variance,
|
||||
plt.plot(xs,n.pdf(xs))
|
||||
plt.xlim((min_x, max_x))
|
||||
|
||||
if ylim is not None:
|
||||
plt.ylim(ylim)
|
||||
|
||||
if mean_line:
|
||||
plt.axvline(mean)
|
||||
if xlabel:
|
||||
|
||||
Reference in New Issue
Block a user