-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_graph.py
More file actions
57 lines (45 loc) · 1.16 KB
/
data_graph.py
File metadata and controls
57 lines (45 loc) · 1.16 KB
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
import json
import numpy as np
from matplotlib import pyplot as plt
'''
input_file = open('getData.json', 'r')
output_file = open('getData.txt', 'w')
'''
f = open("outputDataNotSorted.txt", "r")
Lines = f.readlines()
mylist = []
count = 0
while(count < 1500):
for line in Lines:
data_int = float(line[:len(line)-2])
mylist.append(data_int)
count += 1
x = np.arange(5, len(mylist))
y = np.array(mylist[5:len(mylist)])
plt.title("original data")
plt.xlabel("order of data")
plt.ylabel("time of data")
plt.plot(x, y, '-')
plt.show()
'''
print("length of list: ", len(mylist))
diff_list = []
for i in range(1, len(mylist), 1):
diff = mylist[i]-mylist[i-1]
diff_list.append(diff)
rounded_list = [round(num, 1) for num in diff_list]
# textfile = open("roundedDataNotSorted.txt", "w")
textfile = open("roundedData.txt", "w")
for element in rounded_list:
textfile.write(str(element) + "\n")
textfile.close()
x = np.arange(0, len(rounded_list))
y = np.array(rounded_list)
plt.title("diff_sorted")
plt.xlabel("order")
plt.ylabel("time difference")
plt.plot(x, y, color="green")
plt.ylim(-10000, 20000)
plt.xlim(0,len(rounded_list))
plt.show()
'''