]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Update hatch, remove unused
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 7 Jan 2019 12:47:39 +0000 (13:47 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 7 Jan 2019 12:47:39 +0000 (13:47 +0100)
plot.py

diff --git a/plot.py b/plot.py
index a75d50ee8e23d34dbc611513e3c929c09f5eb532..ba427b59f8b8cf4ce1ac2abb8ceeda9cb6de59bc 100644 (file)
--- a/plot.py
+++ b/plot.py
@@ -15,6 +15,7 @@ WIDTH = 1.625
 
 SCEN_FILE = argv[1]
 TRAJ_FILE = argv[2]
+
 PLOT = {
         "enable" : True,
         "node" : False,
@@ -135,15 +136,18 @@ if __name__ == "__main__":
         pass
 
     plt.rcParams["font.size"] = 24
+    plt.rcParams['hatch.linewidth'] = 1.0
     fig = plt.figure()
+
+    ################
     ## 1st subplot
+
     ax = fig.add_subplot(121)
     ax.set_aspect("equal")
     ax.set_title("Final path")
     ax.set_xlabel("x [m]")
     ax.set_ylabel("y [m]")
 
-    # plot here
     for o in s["obst"]:
         try:
             plt.plot(*plot_nodes(o["segment"]), color="black")
@@ -152,7 +156,7 @@ if __name__ == "__main__":
         try:
             ax.add_artist(plt.Circle((o["circle"][0], o["circle"][1]),
                     o["circle"][2],
-                    color="black", fill=False, hatch="/"))
+                    color="black", fill=False, hatch="//"))
         except:
             pass
     if PLOT["node"]:
@@ -191,7 +195,7 @@ if __name__ == "__main__":
                 if PLOT["frame"]:
                     for i in t["traj"][traj]:
                         plt.plot(*car_frame(i), color=COLOR["log"][traj],
-                                label=t["cost"][traj])
+                                label=t["cost"][traj], lw=1)
                 else:
                     try:
                         plt.plot(
@@ -205,23 +209,45 @@ if __name__ == "__main__":
                                 label=t["cost"][traj])
         except:
             print("No trajectory")
+
     plt.plot(*car_frame(s["init"]), color="red", lw=2)
     plt.plot(*car_frame(s["goal"]), color="red", lw=2)
     plt.plot(*plot_nodes([s["init"]]), color="red", marker="+", ms=12)
     plt.plot(*plot_nodes([s["goal"]]), color="red", marker="+", ms=12)
-    # end plot here
+
+    plt.fill_between(
+                [-2.7, 3.25, 3.25, -2.7],
+                [1.5, 1.5, 2, 2],
+                [26, 26, 26.5, 26.5],
+                facecolor="none", hatch="//", edgecolor="black", linewidth=0)
+    plt.fill_between(
+                [-2.7, -2.7, -0, -0, -2.2, -2.2, 0, 0, -2.7],
+                [1.5, 26.5, 26.5, 19.5, 19.5, 13, 13, 1.5, 1.5],
+                facecolor="none", hatch="//", edgecolor="black", linewidth=0)
+    plt.fill_between(
+                [3.25, 3.25, 2.75, 2.75, 3.25],
+                [1.5, 26.5, 26.5, 1.5, 1.5],
+                facecolor="none", hatch="//", edgecolor="black", linewidth=0)
+
+    #plt.text(1, 0.2, s="1", color="red")
+    #plt.text(2, 12.2, s="2", color="red")
+    #plt.text(3.6, 10, s="3", color="black")
+    #plt.text(-0.5, 14.3, s="4", color="black")
+    #plt.text(3, 18, s="5", color="blue")
+    #plt.text(-4.7, 0.8, s="6", color="orange")
+    #plt.text(-2, 11, s="7", color="gray")
 
     handles, labels = ax.get_legend_handles_labels()
-    #lgd = ax.legend(handles, labels, loc="upper center",
-    #        bbox_to_anchor=(0.5, -0.11), title="Cost")
+
+    ################
     ## 2nd subplot
+
     ax = fig.add_subplot(122)
     ax.set_aspect("equal")
     ax.set_title("All edges")
     ax.set_xlabel("x [m]")
     ax.set_ylabel("y [m]")
 
-    # plot here
     for o in s["obst"]:
         try:
             plt.plot(*plot_nodes(o["segment"]), color="black")
@@ -229,8 +255,8 @@ if __name__ == "__main__":
             pass
         try:
             ax.add_artist(plt.Circle((o["circle"][0], o["circle"][1]),
-                o["circle"][2],
-                color="black", fill=False))
+                    o["circle"][2],
+                    color="black", fill=False, hatch="//"))
         except:
             pass
     if PLOT["node"]:
@@ -244,7 +270,7 @@ if __name__ == "__main__":
             for edges in t["edge"]:
                 for e in edges:
                     plt.plot([e[0][0], e[1][0]], [e[0][1], e[1][1]],
-                            color=COLOR["edge"])
+                            color=COLOR["edge"], lw=1)
         except:
             print("No edges")
     if PLOT["sample"]:
@@ -283,18 +309,28 @@ if __name__ == "__main__":
                                 label=t["cost"][traj])
         except:
             print("No trajectory")
+
     plt.plot(*car_frame(s["init"]), color="red", lw=2)
     plt.plot(*car_frame(s["goal"]), color="red", lw=2)
     plt.plot(*plot_nodes([s["init"]]), color="red", marker="+", ms=12)
     plt.plot(*plot_nodes([s["goal"]]), color="red", marker="+", ms=12)
-    # end plot here
+
+    plt.fill_between(
+                [-2.7, 3.25, 3.25, -2.7],
+                [1.5, 1.5, 2, 2],
+                [26, 26, 26.5, 26.5],
+                facecolor="none", hatch="//", edgecolor="black", linewidth=0)
+    plt.fill_between(
+                [-2.7, -2.7, -0, -0, -2.2, -2.2, 0, 0, -2.7],
+                [1.5, 26.5, 26.5, 19.5, 19.5, 13, 13, 1.5, 1.5],
+                facecolor="none", hatch="//", edgecolor="black", linewidth=0)
+    plt.fill_between(
+                [3.25, 3.25, 2.75, 2.75, 3.25],
+                [1.5, 26.5, 26.5, 1.5, 1.5],
+                facecolor="none", hatch="//", edgecolor="black", linewidth=0)
 
     handles, labels = ax.get_legend_handles_labels()
-    #lgd = ax.legend(handles, labels, loc="upper center",
-    #        bbox_to_anchor=(0.5, -0.11), title="Cost")
 
     # END OF SUBPLOTS
     plt.show()
-    #plt.savefig("{}.png".format(argv[2]), bbox_extra_artists=(lgd,),
-    #        bbox_inches='tight')
     plt.close(fig)