forked from ChexterWang/pcs22
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fig2.py
79 lines (73 loc) · 1.75 KB
/
fig2.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
# plot fig2
from pandas import DataFrame
from plotly.graph_objects import Figure, Scatter
from run import single_run as sr
from numpy import average
# collect data
df = DataFrame(data = dict(
edge = [[] for i in range(7)],
local = [[] for i in range(7)],
partial = [[] for i in range(7)],
),
index=[10, 15, 20, 25, 30, 35, 40],
)
for a in range(10):
print(f'{a}')
for i in df.index:
print(f' {i}')
cal = sr(i)
for j in df.columns:
df.loc[i, j] = df.loc[i, j] + [cal[j]]
for i in df.index:
for j in df.columns:
df.loc[i, j] = average(df.loc[i, j])
# plot fig 2
## config for traces
config = DataFrame(dict(
name = [
'Partial Offloading',
'Local Processing',
'Edge Processing',
],
line = [
dict(color='#FF6600'),
dict(color='#757563'),
dict(color='#4785C4'),
],
), index = ['partial','local','edge',])
## init figure
fig = Figure()
## add trace
for i in config.index:
fig.add_trace(Scatter(x=df.index, y=df[i], name=config.loc[i,'name'], line=config.loc[i,'line']))
## config for figure
fig.update_layout(dict(
title=dict(
text='Fig.2. Maximum delay against the number of devices in three schemes.',
font=dict(size=16),
),
xaxis=dict(
title=dict(
text='Number of devices',
font=dict(size=12),
),
),
yaxis=dict(
title=dict(
text='Max delay of all devices in system(s)',
font=dict(size=12),
),
),
legend=dict(
yanchor='top',
y=0.99,
xanchor='left',
x=0.01,
font=dict(size=11)
),
width=720,
height=480
))
## show and wirte figure
fig.show()
fig.write_image(file='fig2.jpg')