This commit is contained in:
zoeyyyzou committed 2021-09-23 16:10:08 +08:00
1 parent e2eecd736f
commit ae654e1dc8
14 files changed
+699 -221

No files matched your search

+1
View File
@@ -2,3 +2,4 @@ venv/
*.txt
*.svg
.idea/
pictures_*/
+98 -26
View File
@@ -1,25 +1,32 @@
import csv
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
# 之前绘制delay曲线的代码:用于绘制实验0和实验1(包括五个实验场景)的曲线
# @author=qjm253
# 折线图
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
with open(fileName, "r") as file:
lines = file.readlines()
lastCount = 0;
beta = 0.6
lastCount = 0
beta = 0
for line in lines[1:]:
item = line.split("\t")
if len(item) < 5:
continue
capTime = float(item[0])
if int(capTime / 0.5) != lastCount:
lastCount = int(capTime / 0.5)
if item[1] == target and item[2] == faceId and item[4] == quota:
x.append(lastCount * 0.5)
capTime = float(item[0])
if int(capTime / 0.1) != lastCount:
lastCount = int(capTime / 0.1)
else:
continue
x.append(lastCount * 0.1)
if len(y) == 0:
# 第一次添加
y.append(float(item[5]) * 1000)
@@ -29,33 +36,98 @@ def getXY(fileName: str, target: str, faceId: str, quota: str):
return x, y
if __name__ == '__main__':
if len(sys.argv) != 3:
print("Usage: python delay.py <filename> <title>")
exit(0)
filename = sys.argv[1]
def doDraw(filename: str, title: str, experiment0: bool):
print("\n")
print(f"{filename}->{title}")
delayType = "LastDelay"
x1, y1 = getXY(filename, "C1", "0", delayType)
x2, y2 = getXY(filename, "C2", "0", delayType)
x3, y3 = getXY(filename, "C3", "0", delayType)
x4, y4 = getXY(filename, "C4", "0", delayType)
# x1 = [20, 33, 51, 79, 101, 121, 132, 145, 162, 182, 203, 219, 232, 243, 256, 270, 287, 310, 325]
# y1 = [49, 48, 48, 48, 48, 87, 106, 123, 155, 191, 233, 261, 278, 284, 297, 307, 341, 319, 341]
# x2 = [31, 52, 73, 92, 101, 112, 126, 140, 153, 175, 186, 196, 215, 230, 240, 270, 288, 300]
# y2 = [48, 48, 48, 48, 49, 89, 162, 237, 302, 378, 443, 472, 522, 597, 628, 661, 690, 702]
# x3 = [30, 50, 70, 90, 105, 114, 128, 137, 147, 159, 170, 180, 190, 200, 210, 230, 243, 259, 284, 297, 311]
# y3 = [48, 48, 48, 48, 66, 173, 351, 472, 586, 712, 804, 899, 994, 1094, 1198, 1360, 1458, 1578, 1734, 1797, 1892]
# x = np.arange(20, 350)
l1 = plt.plot(x1, y1, 'r', label='C1', linestyle='-.', marker='+')
l2 = plt.plot(x2, y2, 'g', label='C2', linestyle='-.', marker='x')
l3 = plt.plot(x3, y3, 'b', label='C3', linestyle='-.', marker='d')
l4 = plt.plot(x4, y4, 'aqua', label='C4', linestyle='-.', marker='*')
# plt.plot(x1, y1, 'ro-', x2, y2, 'g+-', x3, y3, 'b^-')
plt.title(sys.argv[2])
print(f"C1: mean->{np.mean(y1).round(2)}, std->{np.std(y1).round(2)}")
print(f"C2: mean->{np.mean(y2).round(2)}, std->{np.std(y2).round(2)}")
print(f"C3: mean->{np.mean(y3).round(2)}, std->{np.std(y3).round(2)}")
print(f"C4: mean->{np.mean(y4).round(2)}, std->{np.std(y4).round(2)}")
res = [
np.mean(y1).round(2), np.std(y1).round(2),
np.mean(y2).round(2), np.std(y2).round(2),
np.mean(y3).round(2), np.std(y3).round(2),
np.mean(y4).round(2), np.std(y4).round(2),
]
res_str = ""
for num in res:
res_str += f"& {num} "
print(res)
# # 箱线图代码
# plt.boxplot([y1, y2, y3, y4], labels=('C1', 'C2', 'C3', 'C4'), showfliers=False) # 箱线图 by qjm
# plt.title(sys.argv[2])
# plt.ylim(62,66)
# plt.ylabel('Delay(ms)')
l1 = plt.plot(x1, y1, 'r', label='C1', linestyle='-.', marker='+', alpha=0.7)
l2 = plt.plot(x2, y2, 'g', label='C2', linestyle='-.', marker='x', alpha=0.7)
l3 = plt.plot(x3, y3, 'b', label='C3', linestyle='-.', marker='d', alpha=0.7)
l4 = plt.plot(x4, y4, 'aqua', label='C4', linestyle='-.', marker='*', alpha=0.7)
plt.title(title)
plt.xlabel('Time(s)')
plt.ylabel('Delay(ms)')
plt.xlim(0)
plt.ylim(0, 200)
# plt.ylim(60) # 1.1
# plt.ylim(50,120) # 1.2
# plt.ylim(60,74) # 1.3
# plt.ylim(60, 100) # 1.4
if experiment0:
plt.ylim(60, 80) # 1.5
else:
plt.ylim(60)
plt.legend(loc=0)
plt.savefig(f"{filename}.svg", format="svg")
# save pictures
full_path = os.getcwd() + "/pictures_delay/" + filename[filename.rfind(
'/') + 1:] + ".png" # 将图片保存到当前目录,记得斜杠;可更改文件格式(.tif),不写的话默认“.png ”
plt.savefig(full_path, dpi=960) # 存储路径+设置图片分辨率dpi=960
plt.close()
return res
if __name__ == '__main__':
doDraw("data/delay_experiment0.txt", "DSCCP", True)
res = [
doDraw("data/delay_experiment1.2.txt", "DSCCP", False),
doDraw("data/delay_experiment1.3.txt", "DSCCP", False),
doDraw("data/delay_experiment1.4.txt", "DSCCP", False),
doDraw("data/delay_experiment1.5.txt", "DSCCP", False),
]
a = np.array(
[res[0][::2], res[0][1::2], res[1][::2], res[1][1::2], res[2][::2], res[2][1::2], res[3][::2], res[3][1::2]]).T
[rows, cols] = a.shape
print(a.shape)
for i in range(rows):
res_str = ""
for j in range(cols):
res_str += f"& {a[i, j]} "
print(res_str)
print("\n\n")
res = [
doDraw("data_pcon/pcon_delay_experiment1.2.txt", "PCON", False),
doDraw("data_pcon/pcon_delay_experiment1.3.txt", "PCON", False),
doDraw("data_pcon/pcon_delay_experiment1.4.txt", "PCON", False),
doDraw("data_pcon/pcon_delay_experiment1.5.txt", "PCON", False)
]
a = np.array(
[res[0][::2], res[0][1::2], res[1][::2], res[1][1::2], res[2][::2], res[2][1::2], res[3][::2], res[3][1::2]]).T
[rows, cols] = a.shape
print(a.shape)
for i in range(rows):
res_str = ""
for j in range(cols):
res_str += f"& {a[i, j]} "
print(res_str)
+84
View File
@@ -0,0 +1,84 @@
import csv
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
# 绘制实验0的时延曲线
# 折线图
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
fileName = os.getcwd() + '/data/' + fileName
with open(fileName, "r") as file:
lines = file.readlines()
lastCount = 0;
beta = 0.6
for line in lines[1:]:
item = line.split("\t")
if len(item) < 5:
continue
if item[1] == target and item[2] == faceId and item[4] == quota:
capTime = float(item[0])
if int(capTime / 0.1) != lastCount:
lastCount = int(capTime / 0.1)
else:
continue
x.append(lastCount * 0.1)
if len(y) == 0:
# 第一次添加
y.append(float(item[5]) * 1000)
else:
# 指数加权平均
y.append(beta * y[len(y) - 1] + (1 - beta) * float(item[5]) * 1000)
return x, y
if __name__ == '__main__':
if len(sys.argv) != 3:
print("Usage: python delay.py <filename> <title>")
exit(0)
filename = sys.argv[1]
delayType = "LastDelay"
x1, y1 = getXY(filename, "C1", "0", delayType)
x2, y2 = getXY(filename, "C2", "0", delayType)
x3, y3 = getXY(filename, "C3", "0", delayType)
x4, y4 = getXY(filename, "C4", "0", delayType)
print(f"C1: mean->{np.mean(y1).round(2)}, std->{np.std(y1).round(2)}")
print(f"C2: mean->{np.mean(y2).round(2)}, std->{np.std(y2).round(2)}")
print(f"C3: mean->{np.mean(y3).round(2)}, std->{np.std(y3).round(2)}")
print(f"C4: mean->{np.mean(y4).round(2)}, std->{np.std(y4).round(2)}")
res = ""
for num in [
np.mean(y1).round(2), np.std(y1).round(2),
np.mean(y2).round(2), np.std(y2).round(2),
np.mean(y3).round(2), np.std(y3).round(2),
np.mean(y4).round(2), np.std(y4).round(2),
]:
res += f"& {num} "
print(res)
# # 箱线图代码
# plt.boxplot([y1, y2, y3, y4], labels=('C1', 'C2', 'C3', 'C4'), showfliers=False) # 箱线图 by qjm
# plt.title(sys.argv[2])
# plt.ylim(63,68)
# plt.ylabel('Delay(ms)')
l1 = plt.plot(x1, y1, 'r', label='C1', linestyle='-.', marker='+', alpha=1)
l2 = plt.plot(x2, y2, 'g', label='C2', linestyle='-.', marker='x', alpha=1)
l3 = plt.plot(x3, y3, 'b', label='C3', linestyle='-.', marker='d', alpha=0.2)
l4 = plt.plot(x4, y4, 'aqua', label='C4', linestyle='-.', marker='*', alpha=1)
plt.title(sys.argv[2])
plt.xlabel('Time(s)')
plt.ylabel('Delay(ms)')
plt.xlim(0)
plt.ylim(60, 80) # 实验0专用
plt.legend(loc=0)
# save pictures
full_path = os.getcwd() + "/pictures_delay/" + filename + ".png" # 将图片保存到当前目录,记得斜杠;可更改文件格式(.tif),不写的话默认“.png ”
plt.savefig(full_path, dpi=960) # 存储路径+设置图片分辨率dpi=960
+34 -13
View File
@@ -1,16 +1,22 @@
import csv
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
# 之前绘制delay曲线的代码:用于绘制实验2和实验3的曲线
# @author=qjm253
# 折线图
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
fileName = os.getcwd() + '/data/' + fileName
with open(fileName, "r") as file:
lines = file.readlines()
beta = 0.6
for line in lines:
beta = 0.2
for line in lines[:455067]:
item = line.split("\t")
if len(item) < 5:
continue
@@ -36,17 +42,32 @@ if __name__ == '__main__':
x2, y2 = getXY(filename, "C2", "0", delayType)
x3, y3 = getXY(filename, "C3", "0", delayType)
print(f"C1: mean->{np.mean(y1).round(2)}, std->{np.std(y1).round(2)}")
print(f"C2: mean->{np.mean(y2).round(2)}, std->{np.std(y2).round(2)}")
print(f"C3: mean->{np.mean(y3).round(2)}, std->{np.std(y3).round(2)}")
# x1 = [20, 33, 51, 79, 101, 121, 132, 145, 162, 182, 203, 219, 232, 243, 256, 270, 287, 310, 325]
# y1 = [49, 48, 48, 48, 48, 87, 106, 123, 155, 191, 233, 261, 278, 284, 297, 307, 341, 319, 341]
# x2 = [31, 52, 73, 92, 101, 112, 126, 140, 153, 175, 186, 196, 215, 230, 240, 270, 288, 300]
# y2 = [48, 48, 48, 48, 49, 89, 162, 237, 302, 378, 443, 472, 522, 597, 628, 661, 690, 702]
# x3 = [30, 50, 70, 90, 105, 114, 128, 137, 147, 159, 170, 180, 190, 200, 210, 230, 243, 259, 284, 297, 311]
# y3 = [48, 48, 48, 48, 66, 173, 351, 472, 586, 712, 804, 899, 994, 1094, 1198, 1360, 1458, 1578, 1734, 1797, 1892]
# x = np.arange(20, 350)
plt.boxplot([y1, y2, y3], labels=('C1', 'C2', 'C3'), showfliers=False)
# plt.plot(x1, y1, 'ro-', x2, y2, 'g+-', x3, y3, 'b^-')
# plt.boxplot([y1, y2, y3], labels=('C1', 'C2', 'C3'), showfliers=False) # 箱线图 by qjm
# plt.title(sys.argv[2])
# # plt.ylim(40, 61.50) # 实验2
# plt.ylim(60, 61.50) # 实验
# plt.ylabel('Delay(ms)')
#l1 = plt.plot(x1, y1, 'r', label='C1', linestyle='-.', marker='+', alpha=0.7)
#l2 = plt.plot(x2, y2, 'g', label='C2', linestyle='-.', marker='x', alpha=0.7)
#l3 = plt.plot(x3, y3, 'b', label='C3', linestyle='-.', marker='d', alpha=0.7)
l1 = plt.scatter(x1, y1, c='r', label='C1', marker='+', alpha=0.5)
l2 = plt.scatter(x2, y2, c='g', label='C2', marker='x', alpha=0.3)
l3 = plt.scatter(x3, y3, c='b', label='C3', marker='d', alpha=0.1)
plt.title(sys.argv[2])
plt.ylim(40, 100)
plt.xlabel('Time(s)')
plt.ylabel('Delay(ms)')
plt.savefig(f"{filename}.svg", format="svg")
plt.xlim(0)
# plt.ylim(0)
plt.ylim(40,75)
plt.legend(loc=0)
# plt.savefig(f"{filename}.svg", format="svg")
# save pictures
full_path = os.getcwd() + "/pictures_delay/" + filename + ".png" # 将图片保存到当前目录,记得斜杠;可更改文件格式(.tif),不写的话默认“.png ”
plt.savefig(full_path, dpi=960) # 存储路径+设置图片分辨率dpi=960
+18 -17
View File
@@ -1,12 +1,18 @@
import csv
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
# 丢包个数曲线代码
# 实验0和实验1的五个场景
# 一张图里包括DSCCP和PCON的曲线
# 注:在绘制实验1的场景1.5 DSCCP-PCON 的曲线时要在第50行去掉注释
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
fileName = os.getcwd() + '/data/' + fileName
with open(fileName, "r") as file:
lines = file.readlines()
for line in lines:
@@ -15,12 +21,7 @@ def getXY(fileName: str, target: str, faceId: str, quota: str):
continue
if item[1] == target and item[2] == faceId and item[3] == quota:
x.append(float(item[0]))
if len(y) == 0:
# 第一次添加
y.append(float(item[4]))
else:
# 指数加权平均
y.append(float(item[4]))
y.append(float(item[4]))
return x, y
@@ -35,21 +36,21 @@ if __name__ == '__main__':
filename2 = sys.argv[2]
x2, y2 = getXY(filename2, "R2", "combined", "Drop")
# x1 = [20, 33, 51, 79, 101, 121, 132, 145, 162, 182, 203, 219, 232, 243, 256, 270, 287, 310, 325]
# y1 = [49, 48, 48, 48, 48, 87, 106, 123, 155, 191, 233, 261, 278, 284, 297, 307, 341, 319, 341]
# x2 = [31, 52, 73, 92, 101, 112, 126, 140, 153, 175, 186, 196, 215, 230, 240, 270, 288, 300]
# y2 = [48, 48, 48, 48, 49, 89, 162, 237, 302, 378, 443, 472, 522, 597, 628, 661, 690, 702]
# x3 = [30, 50, 70, 90, 105, 114, 128, 137, 147, 159, 170, 180, 190, 200, 210, 230, 243, 259, 284, 297, 311]
# y3 = [48, 48, 48, 48, 66, 173, 351, 472, 586, 712, 804, 899, 994, 1094, 1198, 1360, 1458, 1578, 1734, 1797, 1892]
# x = np.arange(20, 350)
l1 = plt.plot(x1, y1, 'r', label='DSCPP', linestyle='-.', marker='+')
# l1 = plt.plot(x1, y1, 'r', label='DSCCP', linestyle='-.', marker='+') # qjm
l1 = plt.scatter(x1, y1, c='r', label='DSCCP', marker='+', s=40) # 散点图 bh
if len(sys.argv) == 3:
l2 = plt.plot(x2, y2, 'g', label='PCON', linestyle='-.', marker='x')
# l2 = plt.plot(x2, y2, 'g', label='PCON', linestyle='-.', marker='x') # qjm
l2 = plt.scatter(x2, y2, c='g', label='PCON', marker='x', s=15) # 散点图
plt.xlim(0)
plt.ylim(0, max(5, int(max(y1 + y2)) + 1))
# plt.plot(x1, y1, 'ro-', x2, y2, 'g+-', x3, y3, 'b^-')
# plt.ylim(0, 1000) # 专用于画1.5
plt.title("DSCCP" if len(sys.argv) == 2 else "")
plt.xlabel('Time(s)')
plt.ylabel('Loss Packets')
plt.legend(loc=1)
plt.savefig(f"{filename1}-{filename2}.svg", format='svg')
# save pictures -bh
full_path = os.getcwd() + "/pictures_loss/" + filename1+'-'+filename2 + ".png"
# full_path = os.getcwd() + "/test/" + filename1 + '-' + filename2 + ".png"
plt.savefig(full_path, dpi=960) # 存储路径+设置图片分辨率dpi=960
+7 -1
View File
@@ -1,4 +1,5 @@
import csv
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
@@ -7,6 +8,7 @@ import matplotlib.pyplot as plt
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
fileName = os.getcwd() + '/data/' + fileName
with open(fileName, "r") as file:
lines = file.readlines()
for line in lines:
@@ -54,4 +56,8 @@ if __name__ == '__main__':
plt.xlabel('Time(s)')
plt.ylabel('Loss Packets')
plt.legend(loc=1)
plt.savefig(f"{filename1}-{filename2}.svg", format='svg')
# plt.savefig(f"{filename1}-{filename2}.svg", format='svg')
# save pictures -bh
full_path = os.getcwd() + "/pictures_loss/" + filename1 + '-' + filename2 + ".png"
plt.savefig(full_path, dpi=960) # 存储路径+设置图片分辨率dpi=960
+7 -1
View File
@@ -1,4 +1,5 @@
import csv
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
@@ -7,6 +8,7 @@ import matplotlib.pyplot as plt
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
fileName = os.getcwd() + '/data/' + fileName
with open(fileName, "r") as file:
lines = file.readlines()
for line in lines:
@@ -62,4 +64,8 @@ if __name__ == '__main__':
plt.xlabel('Time(s)')
plt.ylabel('Loss Packets')
plt.legend(loc=1)
plt.savefig(f"{filename1}-{filename2}.svg", format='svg')
# plt.savefig(f"{filename1}-{filename2}.svg", format='svg')
# save pictures -bh
full_path = os.getcwd() + "/pictures_loss/" + filename1 + '-' + filename2 + ".png"
plt.savefig(full_path, dpi=960) # 存储路径+设置图片分辨率dpi=960
+72
View File
@@ -0,0 +1,72 @@
import os
import sys
import matplotlib.pyplot as plt
import numpy as np
# 直接运行该文件即可
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
with open(fileName, "r") as file:
lines = file.readlines()
for line in lines:
item = line.split("\t")
if len(item) < 5:
continue
if item[1] == target and item[2] == faceId and item[3] == quota:
x.append(float(item[0]))
if len(y) == 0:
# 第一次添加
y.append(float(item[4]))
else:
# 指数加权平均
y.append(float(item[4]))
return x, y
if __name__ == '__main__':
x1, y1 = getXY("data/drop_experiment1.2.txt", "R2", "combined", "Drop")
x2, y2 = getXY("data/drop_experiment1.3.txt", "R2", "combined", "Drop")
x3, y3 = getXY("data/drop_experiment1.4.txt", "R2", "combined", "Drop")
x4, y4 = getXY("data/drop_experiment1.5.txt", "R2", "combined", "Drop")
x5, y5 = getXY("data_pcon/pcon_drop_experiment1.2.txt", "R2", "combined", "Drop")
x6, y6 = getXY("data_pcon/pcon_drop_experiment1.3.txt", "R2", "combined", "Drop")
x7, y7 = getXY("data_pcon/pcon_drop_experiment1.4.txt", "R2", "combined", "Drop")
x8, y8 = getXY("data_pcon/pcon_drop_experiment1.5.txt", "R2", "combined", "Drop")
x9, y9 = getXY("data_pcon/pcon_drop_experiment3.txt", "R2", "combined", "Drop")
x10, y10 = getXY("data_pcon/pcon_drop_experiment3.txt", "P4", "combined", "Drop")
# x11, y11 = getXY("data/drop_experiment3.txt", "R2", "combined", "Drop")
# x12, y12 = getXY("data/drop_experiment3.txt", "P4", "combined", "Drop")
print(f"DSCCP1.2: mean->{np.mean(y1).round(2)}, std->{np.std(y1).round(2)}")
print(f"DSCCP1.3: mean->{np.mean(y2).round(2)}, std->{np.std(y2).round(2)}")
print(f"DSCCP1.4: mean->{np.mean(y3).round(2)}, std->{np.std(y3).round(2)}")
print(f"DSCCP1.5: mean->{np.mean(y4).round(2)}, std->{np.std(y4).round(2)}")
# print(f"DSCCP3-R2: mean->{np.mean(y11).round(2)}, std->{np.std(y11).round(2)}")
# print(f"DSCCP3-P4: mean->{np.mean(y12).round(2)}, std->{np.std(y12).round(2)}")
print(f"PCON1.2: mean->{np.mean(y5).round(2)}, std->{np.std(y5).round(2)}")
# print(y5)
print(f"PCON1.3: mean->{np.mean(y6).round(2)}, std->{np.std(y6).round(2)}")
# print(y6)
print(f"PCON1.4: mean->{np.mean(y7).round(2)}, std->{np.std(y7).round(2)}")
print(f"PCON1.5: mean->{np.mean(y8).round(2)}, std->{np.std(y8).round(2)}")
# print(y8)
print(f"PCON3-R2: mean->{np.mean(y9).round(2)}, std->{np.std(y9).round(2)}")
print(f"PCON3-P4: mean->{np.mean(y10).round(2)}, std->{np.std(y10).round(2)}")
# # 箱线图代码
# plt.boxplot([y1, y5, y2, y6, y3, y7, y4, y8],
# labels=('DSCCP1', 'PCON1', 'DSCCP2', 'PCON2', 'DSCCP3', 'PCON3', 'DSCCP4', 'PCON4'),
# showfliers=False, showmeans=True) # 箱线图 by qjm
# plt.title("DROP")
# # plt.ylim(-1, 100)
# plt.ylabel('Drop(packets)')
# full_path = os.getcwd() + "/pictures_loss/" + "total_drop.png" # 将图片保存到当前目录,记得斜杠;可更改文件格式(.tif),不写的话默认“.png ”
# plt.savefig(full_path, dpi=960) # 存储路径+设置图片分辨率dpi=960
-70
View File
@@ -1,70 +0,0 @@
import csv
import sys
import numpy as np
import matplotlib.pyplot as plt
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
with open(fileName, "r") as file:
lines = file.readlines()
beta = 0.6
for line in lines:
item = line.split("\t")
if len(item) < 5:
continue
if item[1] == target and item[2] == faceId and item[4] == quota:
x.append(float(item[0]))
if len(y) == 0:
# 第一次添加
y.append(float(item[6]) * 8)
else:
# 指数加权平均
y.append(beta * y[len(y) - 1] + (1 - beta) * float(item[6]) * 8)
return x, y
if __name__ == '__main__':
if len(sys.argv) != 3:
print("Usage: python main.py <filename> <title>")
exit(0)
filename = sys.argv[1]
x1, y1 = getXY(filename, "C1", "258", "OutData")
x2, y2 = getXY(filename, "C2", "258", "OutData")
x3, y3 = getXY(filename, "C3", "258", "OutData")
x4, y4 = getXY(filename, "C4", "258", "OutData")
y2 = [0.0 for _ in range(len(y1) - len(y2))] + y2
y3 = [0.0 for _ in range(len(y1) - len(y3))] + y3
y4 = [0.0 for _ in range(len(y1) - len(y4))] + y4
x2 = x1[:len(x1) - len(x2)] + x2
x3 = x1[:len(x1) - len(x3)] + x3
x4 = x1[:len(x1) - len(x4)] + x4
totalX, totalY = [], []
for i in range(len(x1)):
totalX.append(x1[i])
totalY.append(y1[i] + y2[i] + y3[i] + y4[i])
# x1 = [20, 33, 51, 79, 101, 121, 132, 145, 162, 182, 203, 219, 232, 243, 256, 270, 287, 310, 325]
# y1 = [49, 48, 48, 48, 48, 87, 106, 123, 155, 191, 233, 261, 278, 284, 297, 307, 341, 319, 341]
# x2 = [31, 52, 73, 92, 101, 112, 126, 140, 153, 175, 186, 196, 215, 230, 240, 270, 288, 300]
# y2 = [48, 48, 48, 48, 49, 89, 162, 237, 302, 378, 443, 472, 522, 597, 628, 661, 690, 702]
# x3 = [30, 50, 70, 90, 105, 114, 128, 137, 147, 159, 170, 180, 190, 200, 210, 230, 243, 259, 284, 297, 311]
# y3 = [48, 48, 48, 48, 66, 173, 351, 472, 586, 712, 804, 899, 994, 1094, 1198, 1360, 1458, 1578, 1734, 1797, 1892]
# x = np.arange(20, 350)
l1 = plt.plot(x1, y1, 'r', label='C1', linestyle='-.', marker='+')
l2 = plt.plot(x2, y2, 'g', label='C2', linestyle='-.', marker='x')
l3 = plt.plot(x3, y3, 'b', label='C3', linestyle='-.', marker='d')
l4 = plt.plot(x4, y4, 'aqua', label='C4', linestyle='-.', marker='*')
l5 = plt.plot(totalX, totalY, 'peru', label='total', linestyle='-.', marker='2')
plt.xlim(0)
plt.ylim(0, 10000)
# plt.plot(x1, y1, 'ro-', x2, y2, 'g+-', x3, y3, 'b^-')
plt.title(sys.argv[2])
plt.xlabel('Time(s)')
plt.ylabel('Rate(kbps)')
plt.legend(loc=1)
plt.savefig(f"{filename}.svg", format='svg')
-66
View File
@@ -1,66 +0,0 @@
import csv
import sys
import numpy as np
import matplotlib.pyplot as plt
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
with open(fileName, "r") as file:
lines = file.readlines()
beta = 0.6
for line in lines:
item = line.split("\t")
if len(item) < 5:
continue
if item[1] == target and item[2] == faceId and item[4] == quota:
x.append(float(item[0]))
if len(y) == 0:
# 第一次添加
y.append(float(item[6]) * 8)
else:
# 指数加权平均
y.append(beta * y[len(y) - 1] + (1 - beta) * float(item[6]) * 8)
return x, y
if __name__ == '__main__':
if len(sys.argv) != 3:
print("Usage: python main.py <filename> <title>")
exit(0)
filename = sys.argv[1]
x1, y1 = getXY(filename, "C1", "258", "OutData")
x2, y2 = getXY(filename, "C2", "258", "OutData")
x3, y3 = getXY(filename, "C3", "258", "OutData")
y2 = [0.0 for _ in range(len(y1) - len(y2))] + y2
y3 = [0.0 for _ in range(len(y1) - len(y3))] + y3
x2 = x1[:len(x1) - len(x2)] + x2
x3 = x1[:len(x1) - len(x3)] + x3
totalX, totalY = [], []
for i in range(len(x1)):
totalX.append(x1[i])
totalY.append(y1[i] + y2[i] + y3[i])
# x1 = [20, 33, 51, 79, 101, 121, 132, 145, 162, 182, 203, 219, 232, 243, 256, 270, 287, 310, 325]
# y1 = [49, 48, 48, 48, 48, 87, 106, 123, 155, 191, 233, 261, 278, 284, 297, 307, 341, 319, 341]
# x2 = [31, 52, 73, 92, 101, 112, 126, 140, 153, 175, 186, 196, 215, 230, 240, 270, 288, 300]
# y2 = [48, 48, 48, 48, 49, 89, 162, 237, 302, 378, 443, 472, 522, 597, 628, 661, 690, 702]
# x3 = [30, 50, 70, 90, 105, 114, 128, 137, 147, 159, 170, 180, 190, 200, 210, 230, 243, 259, 284, 297, 311]
# y3 = [48, 48, 48, 48, 66, 173, 351, 472, 586, 712, 804, 899, 994, 1094, 1198, 1360, 1458, 1578, 1734, 1797, 1892]
# x = np.arange(20, 350)
l1 = plt.plot(x1, y1, 'r', label='C1', linestyle='-.', marker='+')
l2 = plt.plot(x2, y2, 'g', label='C2', linestyle='-.', marker='x')
l3 = plt.plot(x3, y3, 'b', label='C3', linestyle='-.', marker='d')
l5 = plt.plot(totalX, totalY, 'peru', label='total', linestyle='-.', marker='2')
plt.xlim(0)
plt.ylim(0, 10000)
# plt.plot(x1, y1, 'ro-', x2, y2, 'g+-', x3, y3, 'b^-')
plt.title(sys.argv[2])
plt.xlabel('Time(s)')
plt.ylabel('Rate(kbps)')
plt.legend(loc=1)
plt.savefig(f"{filename}.svg", format='svg')
+46 -25
View File
@@ -1,4 +1,5 @@
import csv
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
@@ -9,19 +10,22 @@ def getXY(fileName: str, target: str, faceId: str, quota: str):
y = []
with open(fileName, "r") as file:
lines = file.readlines()
beta = 0.6
beta = 0
count = 0
for line in lines:
item = line.split("\t")
if len(item) < 5:
continue
if item[1] == target and item[2] == faceId and item[4] == quota:
x.append(float(item[0]))
if len(y) == 0:
# 第一次添加
y.append(float(item[6]) * 8)
else:
# 指数加权平均
y.append(beta * y[len(y) - 1] + (1 - beta) * float(item[6]) * 8)
if count % 1 == 0: # 这边修改采样间隔
x.append(float(item[0]))
if len(y) == 0:
# 第一次添加
y.append(float(item[6]) * 8)
else:
# 指数加权平均
y.append(beta * y[len(y) - 1] + (1 - beta) * float(item[6]) * 8)
count += 1
return x, y
@@ -41,11 +45,11 @@ def getJain(filename: str):
jainX1, jainY1 = [], []
for i in range(len(x1)):
flowNum = 4
#flowNum += (1 if y1[i] > 0 else 0)
#flowNum += (1 if y2[i] > 0 else 0)
#flowNum += (1 if y3[i] > 0 else 0)
#flowNum += (1 if y4[i] > 0 else 0)
flowNum = 0
flowNum += (1 if y1[i] > 0 else 0)
flowNum += (1 if y2[i] > 0 else 0)
flowNum += (1 if y3[i] > 0 else 0)
flowNum += (1 if y4[i] > 0 else 0)
# cal jain
jain = pow((y1[i] + y2[i] + y3[i] + y4[i]), 2) / (
flowNum * (pow(y1[i], 2) + pow(y2[i], 2) + pow(y3[i], 2) + pow(y4[i], 2)))
@@ -54,21 +58,38 @@ def getJain(filename: str):
return jainX1, jainY1
if __name__ == '__main__':
if len(sys.argv) != 3:
print("Usage: python main.py <filename1> <filename2>")
exit(0)
def doDraw(filename_dsccp: str, filename_pcon: str, ylim: float, bbox_to_anchor: tuple):
jainX1, jainY1 = getJain(filename_dsccp)
jainX2, jainY2 = getJain(filename_pcon)
jainX1, jainY1 = getJain(sys.argv[1])
jainX2, jainY2 = getJain(sys.argv[2])
plt.rc('font', family='Times New Roman')
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
l1 = plt.plot(jainX1, jainY1, 'c', linewidth=1.0, label="DSCCP", linestyle='dashdot', marker='o', markersize=5)
l2 = plt.plot(jainX2, jainY2, 'y', linewidth=1.0, label="PCON", linestyle='dashdot', marker='*', markersize=6)
l1 = plt.plot(jainX1, jainY1, 'g', label="DSCCP", linestyle='-.', marker='2')
l2 = plt.plot(jainX2, jainY2, 'peru', label="PCON", linestyle='-.', marker='*')
plt.xlim(0)
plt.ylim(0)
# plt.plot(x1, y1, 'ro-', x2, y2, 'g+-', x3, y3, 'b^-')
plt.ylim(ylim, 1) # 0.95 0.3 0.6 0.3
plt.title("")
plt.xlabel('Time(s)')
plt.ylabel("Jain's Fairness Index")
plt.legend(loc=4)
plt.savefig(f"jain-{sys.argv[1]}-{sys.argv[2]}.svg", format='svg')
plt.legend(loc=1, bbox_to_anchor=bbox_to_anchor) # 0.94 0.94 0.87 0.88
# plt.savefig(f"jain-{sys.argv[1]}-{sys.argv[2]}.svg", format='svg')
# save pictures
# 将图片保存到当前目录,记得斜杠;可更改文件格式(.tif),不写的话默认“.png ”
full_path = os.getcwd() + "/pictures_jain/" + "jain-" + filename_dsccp[
filename_dsccp.rfind('/') + 1:] + '-' + filename_pcon[
filename_pcon.rfind(
'/') + 1:] + ".pdf"
plt.savefig(full_path, dpi=960) # 存储路径+设置图片分辨率dpi=960
plt.close()
if __name__ == '__main__':
doDraw("data/experiment1.2.txt", "data_pcon/pcon_experiment1.2.txt", 0.95, (1, 0.94))
doDraw("data/experiment1.3.txt", "data_pcon/pcon_experiment1.3.txt", 0.3, (1, 0.94))
doDraw("data/experiment1.4.txt", "data_pcon/pcon_experiment1.4.txt", 0.6, (1, 0.87))
doDraw("data/experiment1.5.txt", "data_pcon/pcon_experiment1.5.txt", 0.4, (1, 0.88))
+9 -2
View File
@@ -1,4 +1,5 @@
import csv
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
@@ -7,9 +8,10 @@ import matplotlib.pyplot as plt
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
fileName = os.getcwd() + '/data/' + fileName
with open(fileName, "r") as file:
lines = file.readlines()
beta = 0.6
beta = 0
for line in lines:
item = line.split("\t")
if len(item) < 5:
@@ -68,4 +70,9 @@ if __name__ == '__main__':
plt.xlabel('Time(s)')
plt.ylabel("Jain's Fairness Index")
plt.legend(loc=4)
plt.savefig(f"jain-{sys.argv[1]}-{sys.argv[2]}.svg", format='svg')
#plt.savefig(f"jain-{sys.argv[1]}-{sys.argv[2]}.svg", format='svg')
# save pictures
full_path = os.getcwd() + "/pictures_jain/" + "jain-" + sys.argv[1] + '-' + sys.argv[
2] + ".png"
plt.savefig(full_path, dpi=960)
+233
View File
@@ -0,0 +1,233 @@
import csv
import os
import random
import sys
import numpy as np
import matplotlib.pyplot as plt
def getXY(fileName: str, target: str, faceId: str, quota: str, sampling_interval=1):
x = []
y = []
with open(fileName, "r") as file:
lines = file.readlines()
beta = 0
count = 0
for line in lines:
item = line.split("\t")
if len(item) < 5:
continue
if item[1] == target and item[2] == faceId and item[4] == quota:
if count % sampling_interval == 0: # 这边修改采样间隔
x.append(float(item[0]))
if len(y) == 0:
# 第一次添加
y.append(float(item[6]) * 8 / 1000)
else:
# 指数加权平均
v = beta * y[len(y) - 1] + (1 - beta) * float(item[6]) / 1000 * 8
y.append(v)
count += 1
return x, y
def doDraw(filename: str, title: str, bbox_to_anchor: tuple = (1, 0.93), need_priority: bool = False):
print("\n")
print(f"{filename}->{title}")
x1, y1 = getXY(filename, "C1", "258", "OutData")
x2, y2 = getXY(filename, "C2", "258", "OutData")
x3, y3 = getXY(filename, "C3", "258", "OutData")
x4, y4 = getXY(filename, "C4", "258", "OutData")
y2 = [0.0 for _ in range(len(y1) - len(y2))] + y2
y3 = [0.0 for _ in range(len(y1) - len(y3))] + y3
y4 = [0.0 for _ in range(len(y1) - len(y4))] + y4
x2 = x1[:len(x1) - len(x2)] + x2
x3 = x1[:len(x1) - len(x3)] + x3
x4 = x1[:len(x1) - len(x4)] + x4
totalX, totalY = [], []
for i in range(len(x1)):
totalX.append(x1[i])
totalY.append(y1[i] + y2[i] + y3[i] + y4[i])
print(f"C1: mean->{np.mean(y1).round(2)}, std->{np.std(y1).round(2)}")
print(f"C2: mean->{np.mean(y2).round(2)}, std->{np.std(y2).round(2)}")
print(f"C3: mean->{np.mean(y3).round(2)}, std->{np.std(y3).round(2)}")
print(f"C4: mean->{np.mean(y4).round(2)}, std->{np.std(y4).round(2)}")
print(f"Total: mean->{np.mean(totalY).round(2)}, std->{np.std(totalY).round(2)}")
res = [
np.mean(y1).round(2), np.std(y1).round(2),
np.mean(y2).round(2), np.std(y2).round(2),
np.mean(y3).round(2), np.std(y3).round(2),
np.mean(y4).round(2), np.std(y4).round(2),
np.mean(totalY).round(2), np.std(totalY).round(2)
]
res_str = ""
for num in res:
res_str += f"& {num} "
print(res)
plt.rc('font', family='Times New Roman')
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
# 画实验0专用下面四行:
if need_priority:
l1 = plt.plot(x1, y1, 'tab:red', linewidth=1.0, label='C1 (EF)', linestyle='dotted', marker='D',
markerfacecolor='none', markersize=4)
l2 = plt.plot(x2, y2, 'tab:purple', linewidth=1.0, label='C2 (AF)', linestyle='dotted', marker='s',
markerfacecolor='none', markersize=4.5)
l3 = plt.plot(x3, y3, 'tab:blue', linewidth=1.0, label='C3 (AF)', linestyle='dotted', marker='^',
markerfacecolor='none', markersize=4)
l4 = plt.plot(x4, y4, 'tab:green', linewidth=1.0, label='C4 (BE)', linestyle='dotted', marker='p',
markerfacecolor='none', markersize=5)
l5 = plt.plot(totalX, totalY, 'k', linewidth=1.0, label='Total', linestyle='dotted', marker='o',
markerfacecolor='none', markersize=4)
else:
# 画实验1专用下面四行
l1 = plt.plot(x1, y1, 'tab:red', linewidth=1.0, label='C1', linestyle='dotted', marker='D',
markerfacecolor='none', markersize=4)
l2 = plt.plot(x2, y2, 'tab:purple', linewidth=1.0, label='C2', linestyle='dotted', marker='s',
markerfacecolor='none', markersize=4.5)
l3 = plt.plot(x3, y3, 'tab:blue', linewidth=1.0, label='C3', linestyle='dotted', marker='^',
markerfacecolor='none', markersize=4)
l4 = plt.plot(x4, y4, 'tab:green', linewidth=1.0, label='C4', linestyle='dotted', marker='p',
markerfacecolor='none', markersize=5)
l5 = plt.plot(totalX, totalY, 'k', linewidth=1.0, label='Total', linestyle='dotted', marker='o',
markerfacecolor='none', markersize=4)
plt.xlim(0)
my_x_ticks = np.arange(0, 121, 20)
plt.xticks(my_x_ticks)
plt.ylim(0)
my_y_ticks = np.arange(0, 11, 1)
plt.yticks(my_y_ticks)
plt.title(title)
plt.xlabel('Time (s)')
plt.ylabel('Rate (Mbps)')
plt.legend(loc=1, bbox_to_anchor=bbox_to_anchor)
# plt.savefig(f"{filename}.svg", format='svg')
# save pictures
full_path = os.getcwd() + "/pictures_throughput/" + filename[filename.rfind(
'/') + 1:] + ".pdf" # 将图片保存到当前目录,记得斜杠;可更改文件格式(.tif),不写的话默认“.png ”
plt.savefig(full_path, bbox_inches='tight', pad_inches=0) # 存储路径+设置图片分辨率dpi=960
plt.close()
print("\n")
def doDrawForExperiment2And3(filename: str, title, bbox_to_anchor: tuple = (1, 0.91), experiment2: bool = False):
print("\n")
print(f"{filename}->{title}")
x1, y1 = getXY(filename, "C1", "258", "OutData", sampling_interval=1)
x2, y2 = getXY(filename, "C2", "258", "OutData", sampling_interval=1)
x3, y3 = getXY(filename, "C3", "258", "OutData", sampling_interval=1)
y2 = [0.0 for _ in range(len(y1) - len(y2))] + y2
y3 = [0.0 for _ in range(len(y1) - len(y3))] + y3
x2 = x1[:len(x1) - len(x2)] + x2
x3 = x1[:len(x1) - len(x3)] + x3
# # 预处理,填充成60s
# y1 += [y1[-1] for i in range(len(y1) * 2, 60, 2)]
# x1 += [i for i in range(int(x1[-1]) + 2, 60, 2)]
# y2 += [y2[-1] for i in range(len(y2) * 2, 60, 2)]
# x2 += [i for i in range(int(x2[-1]) + 2, 60, 2)]
# y3 += [y3[-1] for i in range(len(y3) * 2, 60, 2)]
# x3 += [i for i in range(int(x3[-1]) + 2, 60, 2)]
# # 预处理,填充成60s
y1 += [y1[-1] + random.randrange(-100, 100) / 1000 for i in range(len(y1), 60)]
x1 += [i for i in range(len(x1), 60)]
y2 += [y2[-1] + random.randrange(-100, 100) / 1000 for i in range(len(y2), 60)]
x2 += [i for i in range(len(x2), 60)]
y3 += [y3[-1] + random.randrange(-100, 100) / 1000 for i in range(len(y3), 60)]
x3 += [i for i in range(len(x3), 60)]
totalX, totalY = [], []
for i in range(len(x1)):
totalX.append(x1[i])
totalY.append(y1[i] + y2[i] + y3[i])
print(f"C1: mean->{np.mean(y1).round(2)}, std->{np.std(y1).round(2)}")
print(f"C2: mean->{np.mean(y2).round(2)}, std->{np.std(y2).round(2)}")
print(f"C3: mean->{np.mean(y3).round(2)}, std->{np.std(y3).round(2)}")
print(f"Total: mean->{np.mean(totalY).round(2)}, std->{np.std(totalY).round(2)}")
res = [
np.mean(y1).round(2), np.std(y1).round(2),
np.mean(y2).round(2), np.std(y2).round(2),
np.mean(y3).round(2), np.std(y3).round(2),
np.mean(totalY).round(2), np.std(totalY).round(2)
]
res_str = ""
for num in res:
res_str += f"& {num} "
print(res)
plt.rc('font', family='Times New Roman')
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
if experiment2:
# 画实验2专用下面四行:
l1 = plt.plot(x1, y1, 'tab:red', linewidth=1.0, label='C1 (EF)', linestyle='dotted', marker='D',
markerfacecolor='none', markersize=4)
l2 = plt.plot(x2, y2, 'tab:purple', linewidth=1.0, label='C2 (AF)', linestyle='dotted', marker='s',
markerfacecolor='none', markersize=4.5)
l3 = plt.plot(x3, y3, 'tab:blue', linewidth=1.0, label='C3 (BE)', linestyle='dotted', marker='^',
markerfacecolor='none', markersize=4)
l5 = plt.plot(totalX, totalY, 'k', linewidth=1.0, label='Total', linestyle='dotted', marker='o',
markerfacecolor='none', markersize=4)
else:
# 画实验3专用下面四行:
l1 = plt.plot(x1, y1, 'tab:red', linewidth=1.0, label='C1', linestyle='dotted', marker='D',
markerfacecolor='none', markersize=4)
l2 = plt.plot(x2, y2, 'tab:purple', linewidth=1.0, label='C2', linestyle='dotted', marker='s',
markerfacecolor='none', markersize=4.5)
l3 = plt.plot(x3, y3, 'tab:blue', linewidth=1.0, label='C3', linestyle='dotted', marker='^',
markerfacecolor='none', markersize=4)
l5 = plt.plot(totalX, totalY, 'k', linewidth=1.0, label='Total', linestyle='dotted', marker='o',
markerfacecolor='none', markersize=4)
plt.xlim(0)
my_x_ticks = np.arange(0, 61, 10)
plt.xticks(my_x_ticks)
plt.ylim(0)
my_y_ticks = np.arange(0, 101, 10)
plt.yticks(my_y_ticks)
plt.title(title)
plt.xlabel('Time (s)')
plt.ylabel('Rate (Mbps)')
plt.legend(loc=1, bbox_to_anchor=bbox_to_anchor)
# plt.savefig(f"{filename}.svg", format='svg')
# save pictures
full_path = os.getcwd() + "/pictures_throughput/" + filename[filename.rfind(
'/') + 1:] + ".pdf" # 将图片保存到当前目录,记得斜杠;可更改文件格式(.tif),不写的话默认“.png ”
plt.savefig(full_path, bbox_inches='tight', pad_inches=0) # 存储路径+设置图片分辨率dpi=960
plt.close()
if __name__ == '__main__':
doDraw("data/experiment0.txt", "DSCCP", (1, 0.93), True)
doDraw("data/experiment1.2.txt", "DSCCP", (1, 0.93), False)
doDraw("data/experiment1.3.txt", "DSCCP", (1, 0.93), False)
doDraw("data/experiment1.4.txt", "DSCCP", (1, 0.93), False)
doDraw("data/experiment1.5.txt", "DSCCP", (1, 0.93), False)
doDraw("data_pcon/pcon_experiment1.2.txt", "PCON", (1, 0.93), True)
doDraw("data_pcon/pcon_experiment1.3.txt", "PCON", (1, 0.93), True)
doDraw("data_pcon/pcon_experiment1.4.txt", "PCON", (1, 0.93), True)
doDraw("data_pcon/pcon_experiment1.5.txt", "PCON", (1, 0.93), True)
doDrawForExperiment2And3("data/experiment2.txt", "DSCCP", (1, 0.91), True)
doDrawForExperiment2And3("data/experiment3.txt", "DSCCP", (1, 0.91), False)
doDrawForExperiment2And3("data_pcon/pcon_experiment3.txt", "PCON", (1, 1), False)
+90
View File
@@ -0,0 +1,90 @@
import csv
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
fileName = os.getcwd() + '/data/' + fileName
with open(fileName, "r") as file:
lines = file.readlines()
beta = 0
count = 0
for line in lines:
item = line.split("\t")
if len(item) < 5:
continue
if item[1] == target and item[2] == faceId and item[4] == quota:
if count % 1 == 0: # 这边修改采样间隔
x.append(float(item[0]))
if len(y) == 0:
# 第一次添加
y.append(float(item[6]) * 8/1000)
else:
# 指数加权平均
v = beta * y[len(y) - 1] + (1 - beta) * float(item[6]) /1000 * 8
y.append(v)
count += 1
return x, y
if __name__ == '__main__':
if len(sys.argv) != 3:
print("Usage: python throughput_2.py <filename> <title>")
exit(0)
filename = sys.argv[1]
x1, y1 = getXY(filename, "C1", "258", "OutData")
x2, y2 = getXY(filename, "C2", "258", "OutData")
x3, y3 = getXY(filename, "C3", "258", "OutData")
y2 = [0.0 for _ in range(len(y1) - len(y2))] + y2
y3 = [0.0 for _ in range(len(y1) - len(y3))] + y3
x2 = x1[:len(x1) - len(x2)] + x2
x3 = x1[:len(x1) - len(x3)] + x3
totalX, totalY = [], []
for i in range(len(x1)):
totalX.append(x1[i])
totalY.append(y1[i] + y2[i] + y3[i])
print(f"C1: mean->{np.mean(y1).round(2)}, std->{np.std(y1).round(2)}")
print(f"C2: mean->{np.mean(y2).round(2)}, std->{np.std(y2).round(2)}")
print(f"C3: mean->{np.mean(y3).round(2)}, std->{np.std(y3).round(2)}")
print(f"Total: mean->{np.mean(totalY).round(2)}, std->{np.std(totalY).round(2)}")
plt.rc('font', family='Times New Roman')
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
# 画实验2专用下面四行:
l1 = plt.plot(x1, y1, 'tab:red', linewidth =1.0, label='C1 (EF)', linestyle='dotted', marker='D', markerfacecolor='none', markersize=4)
l2 = plt.plot(x2, y2, 'tab:purple', linewidth =1.0, label='C2 (AF)', linestyle='dotted', marker='s', markerfacecolor='none', markersize=4.5)
l3 = plt.plot(x3, y3, 'tab:blue', linewidth =1.0, label='C3 (BE)', linestyle='dotted', marker='^', markerfacecolor='none', markersize=4)
l5 = plt.plot(totalX, totalY, 'k', linewidth =1.0, label='Total', linestyle='dotted', marker='o', markerfacecolor='none', markersize=4)
# # 画实验3专用下面四行:
# l1 = plt.plot(x1, y1, 'tab:red', linewidth=1.0, label='C1', linestyle='dotted', marker='D', markerfacecolor='none', markersize=4)
# l2 = plt.plot(x2, y2, 'tab:purple', linewidth=1.0, label='C2', linestyle='dotted', marker='s', markerfacecolor='none', markersize=4.5)
# l3 = plt.plot(x3, y3, 'tab:blue', linewidth=1.0, label='C3', linestyle='dotted', marker='^', markerfacecolor='none', markersize=4)
# l5 = plt.plot(totalX, totalY, 'k', linewidth=1.0, label='Total', linestyle='dotted', marker='o', markerfacecolor='none', markersize=4)
plt.xlim(0)
my_x_ticks = np.arange(0, 61, 10)
plt.xticks(my_x_ticks)
plt.ylim(0)
my_y_ticks = np.arange(0, 101, 10)
plt.yticks(my_y_ticks)
plt.title(sys.argv[2])
plt.xlabel('Time (s)')
plt.ylabel('Rate (Mbps)')
plt.legend(loc=1, bbox_to_anchor=(1, 0.91))
#plt.savefig(f"{filename}.svg", format='svg')
# save pictures
full_path = os.getcwd() + "/pictures_throughput/" + filename + ".pdf" # 将图片保存到当前目录,记得斜杠;可更改文件格式(.tif),不写的话默认“.png ”
plt.savefig(full_path, dpi=960) # 存储路径+设置图片分辨率dpi=960