-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplot_paper.py
executable file
·185 lines (155 loc) · 6.51 KB
/
plot_paper.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time :2022/1/6 7:14 PM
# @Author :Ruizhi Cheng
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import matplotlib
import os
ROOT = '../Worlds/dis/0406_dis/downlink_shooting_1/wireshark'
U1_FILENAME = 'dis_udp_process.csv'
# U2_FILENAME = 'U2.csv'
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
dash_line = {0:'-',1:'--',2:'-.'}
####create a figure
#[[trace,label],[trace,label],[trace,label]]
def plot_trace(trace_and_label,xlabel,ylabel):
x = np.arange(1, len(trace_and_label[0][0]) + 1, 1)
fig, ax1 = plt.subplots()
ax1.set_xlabel(xlabel, fontsize=90)
ax1.set_ylabel(ylabel, fontsize=90)
##linewidth = 8 or 15
for i in range(len(trace_and_label)):
ax1.plot(x, trace_and_label[i][0],label=trace_and_label[i][1],linewidth = 8)
print(x)
ax1.spines['top'].set_visible(False)
ax1.spines['right'].set_visible(False)
### 120 or 80
ax1.tick_params(axis='x', labelsize = 90)
ax1.tick_params(axis='y', labelsize = 90)
#ax1.set_yticks(np.arange(0,0.151,0.05))
####### Worlds Tput
# ax1.set_ylim([0, 950])
# ax1.set_xlim([0.1, 130])
# ax1.set_yticks([0,300,500,700])
# ax1.set_xticks([60,120,180])
# ax1.text(63, 80, 'Worlds', fontsize=120, color='red')
#####recroom tput
# ax1.set_ylim([0, 75])
# ax1.set_xlim([0.1, 130])
# ax1.set_yticks([0, 20,40,60])
# ax1.set_xticks([60, 120, 180])
# ax1.text(60, 5, 'Rec Room', fontsize=120, color='red')
######worlds uplink disruption
# ax1.set_yticks([0,300,500,700])
# ax1.set_xticks([60,120,180])
#######Worlds downlink disruption
ax1.set_xticks([40,80, 120, 160,200, 240, 300])
ax1.set_yticks([0,0.3,0.5,0.7,1.0,1.5])
ax1.set_xlim([0.1, 300])
ax1.set_ylim([0,2.1])
ax1.text(5, 1.6, '1.0', fontsize=90, color='red')
ax1.text(45, 1.6, '0.7', fontsize=90, color='red')
ax1.text(85, 1.6, '0.5', fontsize=90, color='red')
ax1.text(125, 1.6, '0.3', fontsize=90, color='red')
ax1.text(165, 1.6, '0.2', fontsize=90, color='red')
ax1.text(205, 1.6, '0.1', fontsize=90, color='red')
ax1.text(260, 1.6, 'N', fontsize=90, color='red')
##TCP uplink
# ax1.set_xlim([0.1, 310])
# ax1.set_ylim([0,2.1])
# ax1.set_yticks([0, 0.3, 0.5, 0.7, 1.0, 1.5])
# ax1.set_xticks([60, 120, 180, 240, 300])
# ax1.text(20, 1.35, '5s', fontsize=80, color='red')
# ax1.text(70, 1.35, '10s', fontsize=80, color='red')
# ax1.text(130, 1.35, '15s', fontsize=80, color='red')
# ax1.text(185, 1.35, '100%', fontsize=80, color='red')
# ax1.text(260, 1.35, 'N', fontsize=80, color='red')
#
##tput
# ax1.set_xlim([0.1, 310])
# ax1.set_ylim([0,2.1])
# ax1.set_yticks([0, 0.3, 0.5, 0.7, 1.0, 1.5])
# ax1.set_xticks([40, 80, 120, 160, 200, 240, 300])
# ax1.text(5, 1.35, '1.5', fontsize=80, color='red')
# ax1.text(45, 1.35, '1.2', fontsize=80, color='red')
# ax1.text(85, 1.35, '1.0', fontsize=80, color='red')
# ax1.text(125, 1.35, '0.7', fontsize=80, color='red')
# ax1.text(165, 1.35, '0.5', fontsize=80, color='red')
# ax1.text(205, 1.35, '0.3', fontsize=80, color='red')
# ax1.text(260, 1.35, 'N', fontsize=80, color='red')
#Utilization
# ax1.set_yticks([0,50,70,100])
# ax1.set_ylim([0,100])
# ax1.text(5, 20, '1.0', fontsize=90, color='red')
# ax1.text(45, 20, '0.7', fontsize=90, color='red')
# ax1.text(85, 20, '0.5', fontsize=90, color='red')
# ax1.text(125, 20, '0.3', fontsize=90, color='red')
# ax1.text(165, 20, '0.2', fontsize=90, color='red')
# ax1.text(205, 20, '0.1', fontsize=90, color='red')
# ax1.text(260, 20, 'N', fontsize=90, color='red')
# ax1.set_ylim([0, 110])
plt.subplots_adjust(bottom=0.14)
#this is for diruption
# plt.fill_between([91,118], 0, 1.55, # upperbound,downbound
# facecolor='green', # fill color
# edgecolor='red', # edge color
# alpha=0.3) # Transparency
# plt.vlines(160,0,1.55,colors = "black",linestyle="--",linewidth = 10)
# ax1.set_ylim([0, 550])
#ax1.set_ylim([0, 3.1])
plt.grid()
# altspace VR
#plt.legend(fontsize=60, loc='upper center', bbox_to_anchor=(0.23, 1.15))
plt.legend(fontsize=90, loc='upper center', bbox_to_anchor=(0.5, 1.2),ncol=2,columnspacing=0.4)
#plt.legend(fontsize=95, loc='upper center', bbox_to_anchor=(0.5, 1.2), ncol=2)
#plt.legend(fontsize=100, loc='best')
plt.show()
def get_col(filename,col_index):
data = pd.read_csv(filename, encoding='gbk', engine='python', header=None)
x = data.iloc[1:, col_index].astype(float)
return np.array(x)
u1_file = os.path.join(ROOT,U1_FILENAME)
# u1_Downlink_Packet_Size = get_col(u1_file,3)
# u1_Uplink_Packet_Size = get_col(u1_file,4)
# u1_Downlink_Packet_Rate = get_col(u1_file,5)
# u1_Uplink_Packet_Rate= get_col(u1_file,6)
u1_Uplink_Bitrate= get_col(u1_file,1)/1000000
u1_Downlink_Bitrate= get_col(u1_file,2)/1000000
u1_TCP_uplink= get_col(u1_file,3)/1000000
# trace_and_label = [[u1_Uplink_Bitrate,'UDP Uplink'],[u1_Downlink_Bitrate,'UDP Downlink'],[u1_TCP_uplink,'TCP Uplink']]
trace_and_label = [[u1_Uplink_Bitrate,'Uplink'],[u1_Downlink_Bitrate,'Downlink']]
xlabel= 'Time (s)'
ylabel='Throughput (Mbps)'
plot_trace(trace_and_label,xlabel,ylabel)
#
# # u2_file = os.path.join(ROOT,FOLDER,U2_FILENAME)
# # u2_Downlink_Packet_Size = get_col(u2_file,1)
# # u2_Uplink_Packet_Size = get_col(u2_file,2)
# # u2_Downlink_Packet_Rate = get_col(u2_file,3)
# # u2_Uplink_Packet_Rate= get_col(u2_file,4)
# # u2_Downlink_Bitrate= get_col(u2_file,5)/1000000
# # u2_Uplink_Bitrate= get_col(u2_file,6)/1000000
#
# xlabel = 'Time (s)'
# #ylabel1 = 'Packet Size/s (Byte)'
# ylabel2 = 'Packets/s'
# ylabel2 = 'Packets/s'
# ylabel3 = 'Bitrate (Mbps)'
# ########u1#######
# #trace1=[[u1_Uplink_Packet_Size,'Uplink'],[u1_Downlink_Packet_Size,'Downlink']]
# #trace2=[[u1_Uplink_Packet_Rate,'Uplink'],[u1_Downlink_Packet_Rate,'Downlink']]
# trace3=[[u1_Uplink_Bitrate,'Session I'],[u1_Downlink_Bitrate,'Session II']]
# #plot_trace(trace1,xlabel,ylabel1)
# #plot_trace(trace2,xlabel,ylabel2)
# plot_trace(trace3,xlabel,ylabel3)
#
# ########u2#######
# # trace1=[[u2_Uplink_Packet_Size,'Uplink'],[u2_Downlink_Packet_Size,'Downlink']]
# # trace2=[[u1_Uplink_Packet_Rate,'Uplink'],[u1_Downlink_Packet_Rate,'Downlink']]
# # trace3=[[u2_Uplink_Bitrate,'Uplink'],[u2_Downlink_Bitrate,'Downlink']]
# #plot_trace(trace1,xlabel,ylabel1)
# #plot_trace(trace2,xlabel,ylabel2)
# # plot_trace(trace3,xlabel,ylabel3)