Refactor plots.
This commit is contained in:
@@ -8,6 +8,24 @@ import matplotlib
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
# Using seaborn's style
|
||||||
|
#plt.style.use('seaborn')
|
||||||
|
|
||||||
|
tex_fonts = {
|
||||||
|
"pgf.texsystem": "lualatex",
|
||||||
|
# "legend.fontsize": "x-large",
|
||||||
|
# "figure.figsize": (15, 5),
|
||||||
|
"axes.labelsize": 15, # "small",
|
||||||
|
# "axes.titlesize": "x-large",
|
||||||
|
"xtick.labelsize": 15, # "small",
|
||||||
|
"ytick.labelsize": 15, # "small",
|
||||||
|
"legend.fontsize": 15,
|
||||||
|
"axes.formatter.use_mathtext": True,
|
||||||
|
"mathtext.fontset": "dejavusans",
|
||||||
|
}
|
||||||
|
|
||||||
|
#plt.rcParams.update(tex_fonts)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
@@ -87,41 +105,39 @@ if __name__ == "__main__":
|
|||||||
)
|
)
|
||||||
transmission_df = transmission_df.rename(columns={"PCID": "lte_pcid", "PCID.1": "nr_pcid"})
|
transmission_df = transmission_df.rename(columns={"PCID": "lte_pcid", "PCID.1": "nr_pcid"})
|
||||||
|
|
||||||
|
transmission_df.index = transmission_df["arrival_time"]
|
||||||
|
|
||||||
# transmission timeline
|
# transmission timeline
|
||||||
scaley = 1.5
|
scaley = 1.5
|
||||||
scalex = 1.0
|
scalex = 1.0
|
||||||
plt.title("{} with {}".format(transmission_direction, cc_algo))
|
plt.title("{} with {}".format(transmission_direction, cc_algo))
|
||||||
fig, ax = plt.subplots(2, 1, figsize=[6.4 * scaley, 4.8 * scalex])
|
fig, ax = plt.subplots(2, 1, figsize=[6.4 * scaley, 4.8 * scalex])
|
||||||
fig.subplots_adjust(right=0.75)
|
fig.subplots_adjust(right=0.75)
|
||||||
|
fig.suptitle("{} with {}".format(transmission_direction, cc_algo))
|
||||||
ax0 = ax[0]
|
ax0 = ax[0]
|
||||||
ax1 = ax0.twinx()
|
ax1 = ax0.twinx()
|
||||||
ax2 = ax0.twinx()
|
ax2 = ax0.twinx()
|
||||||
ax2.spines.right.set_position(("axes", 3))
|
#ax2.spines.right.set_position(("axes", 1.22))
|
||||||
|
|
||||||
ax00 = ax[1]
|
ax00 = ax[1]
|
||||||
ax01 = ax00.twinx()
|
ax01 = ax00.twinx()
|
||||||
|
|
||||||
transmission_df["lte_handovers"] = transmission_df["lte_pcid"].diff()
|
|
||||||
|
|
||||||
|
|
||||||
lte_handovers = transmission_df[transmission_df.lte_pcid.diff() != 0].index.values
|
|
||||||
nr_handovers = transmission_df[transmission_df.nr_pcid.diff() != 0].index.values
|
|
||||||
|
|
||||||
print(transmission_df["lte_handovers"])
|
|
||||||
print(len(transmission_df["lte_handovers"]))
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Plot vertical lines
|
# Plot vertical lines
|
||||||
for item in lte_handovers[1::]:
|
lte_handovers = transmission_df["lte_pcid"].diff().dropna()
|
||||||
ax00.axvline(item, ymin=0, ymax=1, color='red')
|
for index, value in lte_handovers.items():
|
||||||
for item in nr_handovers[1::]:
|
if value > 0:
|
||||||
ax00.axvline(item, ymin=0, ymax=1, color='red')
|
ax00.axvline(index, ymin=0, ymax=1, color="skyblue", label="4G Handover")
|
||||||
|
|
||||||
|
nr_handovers = transmission_df["nr_pcid"].diff().dropna()
|
||||||
|
for index, value in nr_handovers.items():
|
||||||
|
if value > 0:
|
||||||
|
ax00.axvline(index, ymin=0, ymax=1, color="greenyellow", label="5G Handover")
|
||||||
|
|
||||||
ax0.plot(transmission_df["snd_cwnd"].dropna(), color="lime", linestyle="dashed", label="cwnd")
|
ax0.plot(transmission_df["snd_cwnd"].dropna(), color="lime", linestyle="dashed", label="cwnd")
|
||||||
ax1.plot(transmission_df["srtt"].dropna(), color="red", linestyle="dashdot", label="sRTT")
|
ax1.plot(transmission_df["srtt"].dropna(), color="red", linestyle="dashdot", label="sRTT")
|
||||||
ax2.plot(transmission_df["goodput_rolling"], color="blue", linestyle="solid", label="goodput")
|
ax2.plot(transmission_df["goodput_rolling"], color="blue", linestyle="solid", label="goodput")
|
||||||
ax00.plot(transmission_df["downlink_cqi"].dropna(), color="magenta", linestyle="dotted", label="CQI")
|
ax00.plot(transmission_df["downlink_cqi"].dropna(), color="magenta", linestyle="dotted", label="CQI")
|
||||||
ax01.plot(transmission_df["DL_bandwidth"].dropna(), color="peru", linestyle="dotted", label="DL_bandwidth")
|
ax01.plot(transmission_df["DL_bandwidth"].dropna(), color="peru", linestyle="dotted", label="bandwidth")
|
||||||
|
|
||||||
ax2.spines.right.set_position(("axes", 1.1))
|
ax2.spines.right.set_position(("axes", 1.1))
|
||||||
|
|
||||||
@@ -138,10 +154,13 @@ if __name__ == "__main__":
|
|||||||
ax0.set_ylabel("cwnd")
|
ax0.set_ylabel("cwnd")
|
||||||
ax01.set_ylabel("Bandwidth [MHz]")
|
ax01.set_ylabel("Bandwidth [MHz]")
|
||||||
|
|
||||||
|
fig.legend(loc="lower right")
|
||||||
|
|
||||||
plt.savefig("{}{}_plot.pdf".format(args.save, csv.replace(".csv", "")))
|
plt.savefig("{}{}_plot.pdf".format(args.save, csv.replace(".csv", "")))
|
||||||
#except Exception as e:
|
#except Exception as e:
|
||||||
# print("Error processing file: {}".format(csv))
|
# print("Error processing file: {}".format(csv))
|
||||||
# print(str(e))
|
# print(str(e))
|
||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
|
plt.close(fig)
|
||||||
plt.clf()
|
plt.clf()
|
||||||
|
|||||||
Reference in New Issue
Block a user