-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotgraph.py
More file actions
50 lines (38 loc) · 1.13 KB
/
plotgraph.py
File metadata and controls
50 lines (38 loc) · 1.13 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
import matplotlib.pyplot as plt
f = open("./graph.txt","r");
inp = f.read().split("\n");
f.close()
graph = [ [ [] , [] ] , [ [] , [] ] , [ [] , [] ] ]
for i in range(3):
graph[i][0].append(0)
graph[i][1].append(1)
maxil=-1
maxir=-1
mapp = {}
mapp[5] = 0
mapp[7] = 1
mapp[8] = 2
offset = 1100
for i in inp:
j = i.split(" ")
if (int(j[0])!=5 and int(j[0])!=8 and int(j[0])!=7) or len(j)!=3 or int(j[1])%100 != 0:
continue;
graph[mapp[int(j[0])]][0].append(int(j[1])-offset);
graph[mapp[int(j[0])]][1].append(int(j[2]));
maxil=max(maxil,int(j[1]))
maxir=max(maxir,int(j[2]))
maxil += 10;
maxir += 1;
plt.xlabel("Ticks")
plt.ylabel("Queue")
plt.title("Comparison Chart")
print(graph)
plt.grid(b=True, which='major', color='#666666', linestyle='-')
plt.plot([0],[0])
plt.plot(graph[0][0], graph[0][1], marker='o', linewidth=2, markersize=10,label = 'Process 1')
plt.plot(graph[1][0], graph[1][1], marker='^', linewidth=2, markersize=10,label = 'Process 2')
plt.plot(graph[2][0], graph[2][1], marker='s', linewidth=2, markersize=10,label = 'Process 3')
print(maxil,maxir)
plt.plot([maxil],[maxir])
plt.legend(loc='best')
plt.savefig("graph.png")