-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdraw_graph.py
53 lines (46 loc) · 1.07 KB
/
draw_graph.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
import matplotlib.pyplot as plt
import sys
def draw_all_points(gr):
x = []
y = []
for xi in gr:
for yi in gr[xi]:
if (yi == 'inf'):
continue
x.append(xi)
y.append(yi)
plt.scatter(x, y)
plt.xlabel('Broken links, %')
plt.ylabel('Time')
plt.savefig('fig_all.png', format='png')
plt.show()
def draw_average_points(gr):
x = []
y = []
for xi in gr:
sum = 0
cnt = 0
for yi in gr[xi]:
if (yi == float('inf')):
continue
sum += yi
cnt += 1
x.append(xi)
y.append(sum / cnt)
plt.plot(x, y)
plt.xlabel('Broken links, %')
plt.ylabel('Time')
plt.savefig('fig_average.png', format='png')
plt.show()
curr_x = None
gr = dict() #{ xi : [y1,..,yn] }
for line in sys.stdin:
arr = line.split()
if (len(arr) == 2):
curr_x = float(arr[0])
gr[curr_x] = []
if (len(arr) == 1):
gr[curr_x].append(float(arr[0]))
draw_all_points(gr)
draw_average_points(gr)
print(gr)