]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/blob - scripts/plot_psp.py
Update psp plot with recent results
[hubacji1/iamcar2.git] / scripts / plot_psp.py
1 """Plot psp results."""
2 import matplotlib.pyplot as plt
3
4 RESULTS = [
5 [4.210000,10,10],
6 [4.220000,10,9],
7 [4.230000,9,9],
8 [4.240000,8,8],
9 [4.250000,8,8],
10 [4.260000,8,7],
11 [4.270000,8,7],
12 [4.280000,7,7],
13 [4.290000,6,6],
14 [4.300000,6,6],
15 [4.310000,6,6],
16 [4.320000,6,6],
17 [4.330000,6,5],
18 [4.340000,6,5],
19 [4.350000,6,5],
20 [4.360000,5,5],
21 [4.370000,5,5],
22 [4.380000,4,4],
23 [4.390000,4,4],
24 [4.400000,4,4],
25 [4.410000,4,4],
26 [4.420000,4,4],
27 [4.430000,4,4],
28 [4.440000,4,4],
29 [4.450000,4,4],
30 [4.460000,4,3],
31 [4.470000,4,3],
32 [4.480000,4,3],
33 [4.490000,4,3],
34 [4.500000,4,3],
35 [4.510000,4,3],
36 [4.520000,4,3],
37 [4.530000,4,3],
38 [4.540000,3,3],
39 [4.550000,3,3],
40 [4.560000,3,2],
41 [4.570000,3,2],
42 [4.580000,2,2],
43 [4.590000,2,2],
44 [4.600000,2,2],
45 [4.610000,2,2],
46 [4.620000,2,2],
47 [4.630000,2,2],
48 [4.640000,2,2],
49 [4.650000,2,2],
50 [4.660000,2,2],
51 [4.670000,2,2],
52 [4.680000,2,2],
53 [4.690000,2,2],
54 [4.700000,2,2],
55 [4.710000,2,2],
56 [4.720000,2,2],
57 [4.730000,2,2],
58 [4.740000,2,2],
59 [4.750000,2,2],
60 [4.760000,2,2],
61 [4.770000,2,2],
62 [4.780000,2,2],
63 [4.790000,2,2],
64 [4.800000,2,2],
65 [4.810000,2,2],
66 [4.820000,2,1],
67 [4.830000,2,1],
68 [4.840000,2,1],
69 [4.850000,2,1],
70 [4.860000,2,1],
71 [4.870000,2,1],
72 [4.880000,2,1],
73 [4.890000,2,1],
74 [4.900000,2,1],
75 [4.910000,2,1],
76 [4.920000,2,1],
77 [4.930000,2,1],
78 [4.940000,2,1],
79 [4.950000,2,1],
80 [4.960000,2,1],
81 [4.970000,2,1],
82 [4.980000,2,1],
83 [4.990000,2,1],
84 [5.000000,2,1],
85 [5.010000,2,1],
86 [5.020000,2,1],
87 [5.030000,2,1],
88 [5.040000,2,1],
89 [5.050000,2,1],
90 [5.060000,2,1],
91 [5.070000,2,1],
92 [5.080000,2,1],
93 [5.090000,2,1],
94 [5.100000,2,1],
95 [5.110000,2,1],
96 [5.120000,2,1],
97 [5.130000,2,1],
98 [5.140000,2,1],
99 [5.150000,2,1],
100 [5.160000,1,1],
101 [5.170000,1,1],
102 [5.180000,1,1],
103 [5.190000,1,1],
104 [5.200000,1,1],
105 [5.210000,1,1],
106 [5.220000,1,1],
107 [5.230000,1,0],
108 [5.240000,1,0],
109 [5.250000,1,0],
110 [5.260000,1,0],
111 [5.270000,1,0],
112 [5.280000,1,0],
113 [5.290000,1,0],
114 [5.300000,1,0],
115 [5.310000,1,0],
116 [5.320000,1,0],
117 [5.330000,1,0],
118 [5.340000,1,0],
119 [5.350000,1,0],
120 [5.360000,1,0],
121 [5.370000,1,0],
122 [5.380000,1,0],
123 [5.390000,1,0],
124 [5.400000,1,0],
125 [5.410000,1,0],
126 [5.420000,0,0],
127 ]
128
129 def plot_graph():
130     plt.rcParams["font.family"] = "cmr10"
131     plt.rcParams["font.size"] = 22
132     plt.rcParams['lines.linewidth'] = 2.0
133     plt.rcParams["figure.figsize"] = [12, 5]
134     f, ax = plt.subplots()
135     ax.set_title(TITLE)
136
137     if GRID:
138         ax.minorticks_on()
139         ax.grid(which="major", linestyle="-", linewidth="0.5", color="gray")
140         ax.grid(which="minor", linestyle=":", linewidth="0.5", color="gray")
141     if YLOG:
142         ax.set_yscale("log")
143     if YLIM:
144         ax.set_ylim(YLIM)
145
146     ax.set_xlabel(XLABEL)
147     ax.set_ylabel(YLABEL)
148
149     for i in PLOT:
150         lstyle = "-"
151         lcolor = "blue"
152         if PLOT.index(i) == 0:
153             lstyle = "--"
154             lcolor = "orange"
155         plt.plot(i[0], i[1], linestyle=lstyle, color=lcolor)
156
157     plt.legend(LEGEND)
158     plt.savefig(FILE, bbox_inches="tight")
159     plt.close()
160
161 # cusp
162 TITLE = "``Several reversed trials'' planner"
163 XLABEL = "Parking slot length [m]"
164 YLABEL = "Backward-forward changes [-]"
165 LEGEND = [
166     "Naive guess for goal configuration",
167     "Goal configuration by in-slot planner",
168 ]
169 FILE = "/home/jiri/phd/j1/figs/psp_cusp.pdf"
170 GRID = True
171 YLOG = False
172 YLIM = False
173
174 PLOT = []
175 PLOT.append([[i for (i, j, k) in RESULTS], [j for (i, j, k) in RESULTS]])
176 PLOT.append([[i for (i, j, k) in RESULTS], [k for (i, j, k) in RESULTS]])
177 plot_graph()
178
179 """ SKIP
180 # time
181 TITLE = "Elapsed time of search"
182 XLABEL = "Free space [m]"
183 YLABEL = "Elapsed time [s]"
184 LEGEND = [
185     "Reversed",
186     "BFS",
187 ]
188 FILE = "/home/jiri/phd/j1/figs/psp_time.eps"
189 GRID = False
190 YLOG = False
191 YLIM = [0, 0.008]
192
193 PLOT = []
194 PLOT.append([
195     [0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7],
196 [
197 0.000265486,
198 0.000227139,
199 0.000185683,
200 0.000164569,
201 0.000159377,
202 0.000150449,
203 0.000156013,
204 0.000162367,
205 0.000170662,
206 0.000180358,
207 0.000190428,
208 0.000164781,
209 0.000143604,
210 0.000126686,
211 ],
212
213 ])
214 PLOT.append([
215     [0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7],
216 [
217 0.00744224,
218 0.00442855,
219 0.00324742,
220 0.00195541,
221 0.00177623,
222 0.0016829,
223 0.0016006,
224 0.0011417,
225 0.00106993,
226 0.00103785,
227 0.000948079,
228 0.00072849,
229 0.000691348,
230 0.000705111,
231 ],
232
233 ])
234
235 plot_graph()
236 """