-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_nerc.py
More file actions
348 lines (133 loc) · 4.78 KB
/
plot_nerc.py
File metadata and controls
348 lines (133 loc) · 4.78 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# create a bar graph with dummy data with 2 bars, each element will have 2 data side by side for matplotlib
import matplotlib.pyplot as plt
# data
labels = ['4DoF', '5DoF', '6DoF']
data3 = [1240, 1675, 2074]
data2 = [65, 785, 1078]
data1 = [1167, 882, 992]
title_fontsize = 24
# change title font
plt.rcParams.update({'font.size': 22})
# plot
x = range(len(labels))
width = 0.15
fig, ax = plt.subplots()
ax.bar(x, data1, width, label='16bit count', color='#fc8d62')
ax.bar([i + width for i in x], data2, width, label='32bit count', color='#8da0cb')
ax.bar([i + width*3 for i in x], data3, width, label='Double count', color='#66c2a5')
ax.set_xticks([i + width/2 for i in x])
ax.set_xticklabels(labels)
ax.legend()
# set y axis label
plt.ylabel('KB', fontsize=22)
# set x axis label
plt.xlabel('Robots', fontsize=22)
fig.set_size_inches(12, 7)
# savefig
plt.savefig('bar_graph_op_comparison.png', dpi=600, bbox_inches='tight')
# data
labels = ['4DoF', '5DoF', '6DoF']
data3 = [1240, 1675, 2074]
data2 = [65, 785, 1078]
data1 = [1167, 882, 992]
title_fontsize = 24
# change title font
plt.rcParams.update({'font.size': 22})
# plot
x = range(len(labels))
width = 0.25
fig, ax = plt.subplots()
#ax.bar(x, data1, width, label='16bit count', color='#fc8d62')
#ax.bar([i + width for i in x], data2, width, label='32bit count', color='#8da0cb')
#ax.bar([i + width*3 for i in x], data3, width, label='Double count', color='#66c2a5')
ax.bar(x, data3, width, label='double', color='#fc8d62')
ax.bar([i + width for i in x], data1, width, label='16-bit int', color='#66c2a5')
ax.bar([i + width for i in x], data2, bottom=data1, width=width, label='32-bit int', color='#8da0cb')
ax.set_xticks([i + width/2 for i in x])
ax.set_xticklabels(labels)
ax.legend()
# set y axis label
plt.ylabel('# of operations', fontsize=22)
# set x axis label
plt.xlabel('Robots', fontsize=22)
plt.title("Number of Operations Required for Forward Dynamics", fontsize=title_fontsize)
fig.set_size_inches(12, 7)
# savefig
plt.savefig('bar_graph_op_comparison2.png', dpi=600, bbox_inches='tight')
# plot
labels = ['Double', 'Float', 'Int32', 'Int16']
x = range(len(labels))
data21 = [515, 266, 86, 19]
fig, ax = plt.subplots()
ax.bar([i + width for i in x], data21, width, color='#8da0cb')
ax.set_xticks([i + width for i in x])
ax.set_xticklabels(labels)
# log scale
#plt.yscale('log')
# set y axis label
plt.ylabel('Microsecond', fontsize=22)
# set x axis label
plt.xlabel('Number precision', fontsize=22)
fig.set_size_inches(12, 7)
# set title
plt.title('Runtime in Raspberry Pi Pico for Inverse Dynamics', fontsize=title_fontsize)
# savefig
plt.savefig('bar_graph_pico_runtime.png', dpi=600, bbox_inches='tight')
# plot
labels = ['3DoF', '4DoF']
x = range(len(labels))
data21 = [3.7, 15]
data11 = [215, 515]
fig, ax = plt.subplots()
ax.bar(x, data11, width, label='Naive approach', color='#8da0cb')
ax.bar([i + width for i in x], data21, width, label='Our approach', color='#fc8d62')
ax.set_xticks([i + width/2 for i in x])
ax.set_xticklabels(labels)
ax.legend()
# log scale
plt.yscale('log')
# set y axis label
plt.ylabel('Minutes', fontsize=22)
# set x axis label
plt.xlabel('Robots', fontsize=22)
fig.set_size_inches(12, 7)
# set title
plt.title('Daisy Runtime', fontsize=title_fontsize)
# savefig
plt.savefig('bar_graph_daisy_runtime.png', dpi=600, bbox_inches='tight')
import numpy as np
min_frac_bits = 8
max_frac_bits = 11
min_int_bits = 8
max_int_bits = 11
total_scores = np.array(
[
[0.537, 0.254, 0.246, 0.242],
[0.470, 0.254, 0.246, 0.242],
[0.511, 0.254, 0.246, 0.242],
[0.488, 0.254, 0.246, 0.242]
]
)
fig, ax = plt.subplots()
#plt.plasma()
#plt.jet()
cax = ax.matshow(total_scores)
# Add colorbar
fig.colorbar(cax)
# We want to show all ticks...
ax.set_xticks(np.arange(len(range(min_frac_bits, max_frac_bits+1))))
ax.set_yticks(np.arange(len(range(min_int_bits, max_int_bits+1))))
# ... and label them with the respective list entries
ax.set_xticklabels(range(min_frac_bits, max_frac_bits+1), fontsize=16)
ax.set_yticklabels(range(min_int_bits, max_int_bits+1), fontsize=16)
# Loop over data dimensions and create text annotations, but write the score with 2 decimal points
for i in range(len(range(min_int_bits, max_int_bits+1))):
for j in range(len(range(min_frac_bits, max_frac_bits+1))):
text = ax.text(j, i, f'{total_scores[i, j]:.2f}',
ha="center", va="center", color="w", fontsize=14)
# name the x and y axis
ax.set_xlabel("Fractional Bits", fontsize=22)
ax.set_ylabel("Integer Bits", fontsize=22)
ax.set_title("Avg Euclidean Distance", fontsize=22)
fig.tight_layout()
plt.savefig('heatmap_nerc.png', dpi=600, bbox_inches='tight')