Refactor plots.
This commit is contained in:
@@ -8,6 +8,24 @@ import matplotlib
|
||||
import pandas as pd
|
||||
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__":
|
||||
parser = ArgumentParser()
|
||||
@@ -87,41 +105,39 @@ if __name__ == "__main__":
|
||||
)
|
||||
transmission_df = transmission_df.rename(columns={"PCID": "lte_pcid", "PCID.1": "nr_pcid"})
|
||||
|
||||
transmission_df.index = transmission_df["arrival_time"]
|
||||
|
||||
# transmission timeline
|
||||
scaley = 1.5
|
||||
scalex = 1.0
|
||||
plt.title("{} with {}".format(transmission_direction, cc_algo))
|
||||
fig, ax = plt.subplots(2, 1, figsize=[6.4 * scaley, 4.8 * scalex])
|
||||
fig.subplots_adjust(right=0.75)
|
||||
fig.suptitle("{} with {}".format(transmission_direction, cc_algo))
|
||||
ax0 = ax[0]
|
||||
ax1 = ax0.twinx()
|
||||
ax2 = ax0.twinx()
|
||||
ax2.spines.right.set_position(("axes", 3))
|
||||
#ax2.spines.right.set_position(("axes", 1.22))
|
||||
|
||||
ax00 = ax[1]
|
||||
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
|
||||
for item in lte_handovers[1::]:
|
||||
ax00.axvline(item, ymin=0, ymax=1, color='red')
|
||||
for item in nr_handovers[1::]:
|
||||
ax00.axvline(item, ymin=0, ymax=1, color='red')
|
||||
lte_handovers = transmission_df["lte_pcid"].diff().dropna()
|
||||
for index, value in lte_handovers.items():
|
||||
if value > 0:
|
||||
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")
|
||||
ax1.plot(transmission_df["srtt"].dropna(), color="red", linestyle="dashdot", label="sRTT")
|
||||
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")
|
||||
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))
|
||||
|
||||
@@ -138,10 +154,13 @@ if __name__ == "__main__":
|
||||
ax0.set_ylabel("cwnd")
|
||||
ax01.set_ylabel("Bandwidth [MHz]")
|
||||
|
||||
fig.legend(loc="lower right")
|
||||
|
||||
plt.savefig("{}{}_plot.pdf".format(args.save, csv.replace(".csv", "")))
|
||||
#except Exception as e:
|
||||
# print("Error processing file: {}".format(csv))
|
||||
# print(str(e))
|
||||
counter += 1
|
||||
|
||||
plt.close(fig)
|
||||
plt.clf()
|
||||
|
||||
Reference in New Issue
Block a user