]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/blobdiff - scripts/plot.py
Fix plot when obst in json is null
[hubacji1/iamcar2.git] / scripts / plot.py
old mode 100644 (file)
new mode 100755 (executable)
index cd428cd..07ad716
@@ -43,7 +43,7 @@ def boxplot(w={}, t="", yl=None, lx="Elapsed time [s]", ly=""):
     if yl:
         ax.set_ylim(yl)
     plt.xticks(rotation=45)
-    plt.savefig("out.eps", bbox_inches="tight")
+    plt.savefig("out.pdf", bbox_inches="tight")
     plt.close()
 
 def boxplots(w2=[]):
@@ -58,14 +58,26 @@ def boxplots(w2=[]):
     [w, no_opt, iterations] = w2
 
     key = tuple(w.keys())[0]
-    title = scenario.TITLE.split("/")[-2].split(".json")[0].split("sc")[1].replace("_", "-")
-    ax.set_title("Final path cost, out-of-slot planner, {}, ({} avg. iters.)".format(
-        title,
-        np.average([i for i in iterations[key].values()]),
-    ))
-    ax.set_xlabel("Elapsed time [s]")
+    title = ""
+    try:
+        title = (scenario
+            .TITLE
+            .split("/")[-2]
+            .split(".json")[0]
+            .split("sc")[1]
+            .replace("_", "-")
+        )
+        title = "scenario {}".format(title)
+        title = "Final path cost, {}, ({} avg. iters.)".format(
+            title,
+            np.average([i for i in iterations[key].values()]),
+        )
+    except:
+        pass
+    ax.set_title(title)
+    ax.set_xlabel("Number of iterations [-]")
     ax.set_ylabel("Cost [m]")
-    eax.set_ylabel("Timed-out rate [%]")
+    eax.set_ylabel("Finished with no path [%]")
 
     M = len(w[key][0])
     err_hist = [0 for i in range(M)]
@@ -89,11 +101,11 @@ def boxplots(w2=[]):
     MAX = max(maxes)
     mins = [min(val_list[i]) if len(val_list[i]) > 0 else 0 for i in range(M)]
     MIN = min(mins)
-    ax.set_ylim([MIN -5, MAX +5])
-
     EMAX = max(err_hist)
     EMIN = 0
-    #eax.set_ylim([-EMAX -5, 0])
+
+    ax.set_ylim([0, 100])
+    eax.set_ylim([0, 100])
 
     average = [np.average(val_list[i]) for i in range(M)]
     # 95 and 5 are not used
@@ -215,7 +227,6 @@ def boxplots(w2=[]):
     #    linestyle="--",
     #)
 
-    plt.xticks(range(1, M+1), ["{:.2f}".format(0.1 * (k+1)) for k in range(M)])
     ax.minorticks_on()
 
     ax.tick_params(axis='x', labelrotation=45)
@@ -272,7 +283,7 @@ def barplot(wl=[], t="", yl=None, lx="Entry Point Planner variant [-]", ly=""):
     if yl:
         ax.set_ylim(yl)
     plt.xticks(rotation=45)
-    plt.savefig("out.eps", bbox_inches="tight")
+    plt.savefig("out.pdf", bbox_inches="tight")
     plt.close()
 
 def histplot(w={}, t="", lx="Algorithm computation time [s]", ly="Number of paths found [-]"):
@@ -322,7 +333,7 @@ def histplot(w={}, t="", lx="Algorithm computation time [s]", ly="Number of path
     )
     plt.legend([k for k, v in w.items()])
     plt.xticks(rotation=45)
-    plt.savefig("out.eps", bbox_inches="tight")
+    plt.savefig("out.pdf", bbox_inches="tight")
     plt.close()
 
 if __name__ == "__main__":
@@ -334,10 +345,11 @@ if __name__ == "__main__":
         scenario.DNAME = sys.argv[2]
 
     plt.rcParams["figure.figsize"] = [12, 12]
-    plt.rcParams["font.size"] = 21
+    plt.rcParams["font.size"] = 24
     plt.rcParams["font.family"] = "cmr10"
     plt.rcParams["hatch.linewidth"] = 1.0
     plt.rcParams["lines.linewidth"] = 1.0
+    plt.rc('axes', unicode_minus=False)
 
     if w == "time":
         boxplot(scenario.time(), "Elapsed time", yl=[0.0004, 200], ly="Time [s]")