-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_flooding.py
More file actions
53 lines (43 loc) · 1.28 KB
/
Copy pathplot_flooding.py
File metadata and controls
53 lines (43 loc) · 1.28 KB
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
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import argparse
from style import latexify, grid
ALGO_STYLE = {
"swp": dict(label="SWP", marker="o", ls="-", zorder=3),
"pruned": dict(label="Pruned SP", marker="s", ls="--", zorder=2),
"sp": dict(label="SP", marker="^", ls=":", zorder=1),
}
ALGO_ORDER = ["sp", "pruned", "swp"]
p = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
p.add_argument("--input", required=True)
p.add_argument("--output")
args = p.parse_args()
data = pd.read_csv(args.input)
if args.output:
latexify(columns=1, fig_height=1)
fig, ax = plt.subplots()
sns.lineplot(
data, x="load", y="flooded", hue="algorithm",
err_style="bars", err_kws={"capsize": 3},
hue_order=ALGO_ORDER,
style="algorithm", markers=True, dashes=False,
ax=ax
)
ax.set_xlabel(r"Network load $\rho = \lambda/\mu$")
ax.set_xscale("log")
ax.set_ylabel("\# of capacity\nadvertisement")
grid(ax, "both")
handles, _ = ax.get_legend_handles_labels()
ax.get_legend().remove()
fig.legend(
handles, [ALGO_STYLE[a]["label"] for a in ALGO_ORDER],
loc="lower center", ncol=3, fontsize=9,
bbox_to_anchor=(0.5, 0.95),
)
if args.output:
plt.savefig(args.output, bbox_inches="tight")
else:
plt.show()