-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplots.py
More file actions
57 lines (38 loc) · 1.18 KB
/
plots.py
File metadata and controls
57 lines (38 loc) · 1.18 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
# 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 = ['Robot A', 'Robot B', 'Robot C', 'Robot D']
data1 = [10, 20, 30, 40]
data2 = [20, 30, 40, 50]
# plot
x = range(len(labels))
width = 0.35
fig, ax = plt.subplots()
ax.bar(x, data1, width, label='Naive approach')
ax.bar([i + width for i in x], data2, width, label='Our approach')
ax.set_xticks([i + width/2 for i in x])
ax.set_xticklabels(labels)
ax.legend()
# set y axis label
plt.ylabel('Hz')
# set x axis label
plt.xlabel('Robots')
# set title
plt.title('Optimal controller performance with different robots for X CPU')
# savefig
plt.savefig('bar_graph_robot_performance.png')
# same plot, except the title
fig, ax = plt.subplots()
ax.bar(x, data1, width, label='Our approach')
ax.bar([i + width for i in x], data2, width, label='Naive approach')
ax.set_xticks([i + width/2 for i in x])
ax.set_xticklabels(labels)
ax.legend()
# set y axis label
plt.ylabel('MB')
# set x axis label
plt.xlabel('Robots')
# set title
plt.title('Controller memory usage with different robots for X CPU')
# savefig
plt.savefig('bar_graph_robot_memory.png')