-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot3.py
More file actions
41 lines (30 loc) · 1.65 KB
/
plot3.py
File metadata and controls
41 lines (30 loc) · 1.65 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
import matplotlib.pyplot as plt
import numpy as np
def percentage(base, cost):
return [a/b for a, b in zip(cost, base)]
fig = plt.figure()
ax = fig.add_subplot()
datasets_list = ['Facebook', 'Microsoft', 'pFabric', 'ProjecToR']
global_view_shortest_path_routing = [172, 571, 1848, 2536]
global_view_local_routing = [201, 663, 2030, 3220]
local_view_shortest_path_routing = [189, 580, 2142, 2691]
local_view_local_routing = [219, 677, 2233, 3245]
total_width, n_algos = 0.6, 4
width = total_width / n_algos
x_1 = list(range(len(datasets_list)))
x_2 = [pos + width for pos in x_1]
x_3 = [pos + 2 * width for pos in x_1]
x_4 = [pos + 3 * width for pos in x_1]
ax.bar(x_1, percentage(local_view_local_routing, global_view_shortest_path_routing), width=width, label='1 : global view & shortest path routing', color='#FFCC9D')
ax.bar(x_2, percentage(local_view_local_routing, global_view_local_routing), width=width, label='2 : global view & local routing', color='#F0A389')
ax.bar(x_3, percentage(local_view_local_routing, local_view_shortest_path_routing), width=width, label='3 : local view & shortest path routing', color='#B3BA99')
ax.bar(x_4, percentage(local_view_local_routing, local_view_local_routing), width=width, label='4 : local view & local routing', color='#8994BD')
ax.set_xticks([pos+total_width/2-width/2 for pos in x_1], datasets_list)
ax.set_ylim([0.6, 1.1])
ax.set_yticks([0.2 * i for i in range(3, 6)])
ax.set_xlabel('datasets')
ax.set_ylabel('Cost ratio to "local view & local routing"')
ax.set_title('Communication costs on optimal network structure')
plt.legend(fontsize=6)
plt.savefig('/Users/qingyun/Desktop/master thesis drawing/ILP.pdf')
plt.show()