1 """Procedures for plotting graphs."""
3 import matplotlib.pyplot as plt
8 def boxplot(w={}, t="", yl=None):
14 yl -- Y axis limit [min, max].
16 f, ax = plt.subplots()
18 ax.set_title("{} (log yscale)".format(t))
22 ax.boxplot([v for k, v in w.items()], labels=[k for k, v in w.items()])
40 plt.xticks(rotation="vertical")
41 plt.savefig("out.eps", bbox_inches="tight")
44 def barplot(wl=[], t="", yl=None):
45 """Plot barplot graph.
48 wl -- What to plot list.
50 yl -- Y axis limit [min, max].
56 f, ax = plt.subplots()
61 [v for k, v in w.items()],
62 tick_label=[k for k, v in w.items()],
63 width=1 / (len(wl) + 1),
65 for i in range(1, len(wl) - 1):
68 [j + i * 1/len(wl) for j in range(len(w))],
69 [v for k, v in w.items()],
70 width=1 / (len(wl) + 1),
89 plt.xticks(rotation="vertical")
90 plt.savefig("out.eps", bbox_inches="tight")
93 def histplot(w={}, t=""):
94 """Plot histogram graph.
100 f, ax = plt.subplots()
101 ax.set_title("{} (log yscale)".format(t))
104 for ck, cv in w.items():
106 [v for k, v in w.items() if k == ck],
111 X_WHERE = np.percentile([v for k, v in w.items() if k == ck], [95])
112 plt.axvline(X_WHERE, lw=1, linestyle="--")
129 plt.legend([k for k, v in w.items()])
130 plt.savefig("out.eps", bbox_inches="tight")
133 if __name__ == "__main__":
134 if len(sys.argv) > 1:
139 plt.rcParams["font.size"] = 24
142 boxplot(scenario.time(), "Elapsed time", yl=[0.05, 100])
144 histplot(scenario.time(), "Elapsed time histogram")
146 boxplot(scenario.cost(), "Final path cost", yl=[1, 400])
148 histplot(scenario.cost(), "Final path cost histogram")
150 boxplot(scenario.cusp(), "Changes in direction")
152 histplot(scenario.cusp(), "Changes in direction histogram")
154 barplot(scenario.error_rate(), "Error rate")
156 boxplot(scenario.iter(), "Number of iterations", yl=[1, 1000])
158 print("""The following arguments are allowed:
160 time, htime, cost, hcost, cusp, hcusp, error, iter