-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplot_data.py
147 lines (127 loc) · 3.21 KB
/
plot_data.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import numpy as np
import datetime
import sql_sb
'''contains functions to fetch and plot data'''
def d_vs_S(query_dr):
'''fetches date and sleep from daily_routine'''
cnx = sql_sb.connect_sql()
cursor=cnx.cursor()
sql_sb.connect_db(cursor)
cursor.execute(query_dr)
d=[]
s=[]
for i in cursor.fetchall():
d.append(np.datetime64(i[0]))
s.append(int(i[1]))
cursor.close()
cnx.close()
return d,s;
def d_vs_C(query_dr):
'''fetches date and classes attended from daily_routine'''
cnx=sql_sb.connect_sql()
cursor=cnx.cursor()
sql_sb.connect_db(cursor)
cursor.execute(query_dr)
d=[]
c=[]
for i in cursor.fetchall():
d.append(np.datetime64(i[0]))
c.append(int(i[1]))
cursor.close()
cnx.close()
return d,c;
def d_vs_w(query_dr):
'''fetches date and workout from daily_routine'''
cnx=sql_sb.connect_sql()
cursor=cnx.cursor()
sql_sb.connect_db(cursor)
cursor.execute(query_dr)
d=[]
w=[]
for i in cursor.fetchall():
d.append(np.datetime64(i[0]))
w.append(int(i[1]))
cursor.close()
cnx.close()
return d,w;
def d_vs_qos(query_dr):
'''fetches date and quality of sleep from quality index'''
cnx=sql_sb.connect_sql()
cursor=cnx.cursor()
sql_sb.connect_db(cursor)
cursor.execute(query_dr)
d=[]
q=[]
for i in cursor.fetchall():
d.append(np.datetime64(i[0]))
q.append(int(i[1]))
cursor.close()
cnx.close()
return d,q;
def d_vs_oh(query_dr):
'''this function fetches qualtiy of health and date from quality index'''
cnx=sql_sb.connect_sql()
cursor=cnx.cursor()
sql_sb.connect_db(cursor)
cursor.execute(query_dr)
d=[]
q=[]
for i in cursor.fetchall():
d.append(np.datetime64(i[0]))
q.append(int(i[1]))
cursor.close()
cnx.close()
return d,q;
def pro_plot():
'''plots project infromation'''
query_dr="SELECT PROJECT_NAME,HOURS_SPENT from project"
cnx=sql_sb.connect_sql()
cursor=cnx.cursor()
sql_sb.connect_db(cursor)
cursor.execute(query_dr)
d=[]
q=[]
for i in cursor.fetchall():
d.append((i[0]))
q.append(int(i[1]))
cursor.close()
cnx.close()
plt.bar(d,q)
plt.show()
def plot_DvsQOS():
''''plots date vs qos'''
query_dr="SELECT DATE, QOS from quality_index"
d,q=d_vs_qos(query_dr)
print(d)
plt.plot(d,q)
plt.show()
def plot_DvsQOh():
''''plots date vs qos'''
query_dr="SELECT DATE, OH from quality_index"
d,q=d_vs_oh(query_dr)
print(d)
plt.plot(d,q)
plt.show()
def plot_DvsW():
'''plots date vs workout'''
query_dr="SELECT DATE,WORKOUT from daily_routine"
d,w=d_vs_w(query_dr)
print(d)
plt.plot(d,w)
plt.show()
def plot_DvsC():
'''plots date vs classes attended'''
query_dr="SELECT DATE,CLASSES_ATTENDED from daily_routine"
d,c=d_vs_C(query_dr)
print(d)
plt.plot(d,c)
plt.show()
def plot_DvsS():
'''plots date vs sleep'''
query_dr="SELECT DATE,HOURS_OF_SLEEP from daily_routine"
d,s=d_vs_S(query_dr)
print(d)
plt.plot(d,s)
plt.show()