-
Notifications
You must be signed in to change notification settings - Fork 2
/
visualize.py
36 lines (25 loc) · 851 Bytes
/
visualize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 19 09:17:03 2019
@author: Gaurav Bothra
"""
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (18, 12)
def price(x):
return '$%1.2f' % x
def plot_lstm_prediction(message, actual, prediction, title='Actual vs Prediction', y_label='Price USD', x_label='Trading Days'):
fig = plt.figure()
ax = fig.add_subplot(111)
# Add labels
plt.ylabel(y_label)
plt.xlabel(x_label)
# Plot actual and predicted close values
plt.plot(actual, '#00FF00', label='Adjusted Close')
plt.plot(prediction, '#0000FF', label='Predicted Close')
# Set title
ax.set_title(title)
ax.legend(loc='upper left')
plt.savefig('../static/img/'+message+'result.png')
#plt.show()