Added line for actual weight trend line

This is in response to pull request #257. That hard coded the
line, which meant it had no label in the legend. This adds the
trend line with a label.
This commit is contained in:
Roger Labbe 2018-11-02 14:42:38 -07:00
parent 034f2b809a
commit 20b2e38a22
2 changed files with 30 additions and 32 deletions

File diff suppressed because one or more lines are too long

View File

@ -172,19 +172,18 @@ def plot_estimate_chart_3():
plt.ylim(157, 164.5)
def plot_gh_results(weights, estimates, predictions, time_step=0):
def plot_gh_results(weights, estimates, predictions, actual, time_step=0):
n = len(weights)
if time_step > 0:
rng = range(1, n+1)
else:
rng = range(n, n+1)
xs = range(n+1)
pred, = book_plots.plot_track(xs[1:], predictions, c='r', marker='v')
scale, = book_plots.plot_measurements(xs[1:], weights, color='k', lines=False)
est, = book_plots.plot_filter(xs, estimates, marker='o')
plt.legend([scale, est, pred], ['Measurement', 'Estimates', 'Predictions'], loc=4)
book_plots.plot_measurements(xs[1:], weights, color='k', lines=False)
book_plots.plot_filter(xs, estimates, marker='o', label='Estimates')
book_plots.plot_track(xs[1:], predictions, c='r', marker='v', label='Predictions')
plt.plot([xs[0], xs[-1]], actual, c='k', lw=1, label='Actual')
plt.legend(loc=4)
book_plots.set_labels(x='day', y='weight (lbs)')
plt.xlim([-1, n+1])
plt.ylim([156.0, 173])