-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
26 lines (25 loc) · 1.04 KB
/
utils.py
File metadata and controls
26 lines (25 loc) · 1.04 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
def autolabel(plt, rects, count_list=None):
# attach a text label above each bar in rects, displaying its height
assert len(rects) == len(count_list)
if count_list != None:
for rect, count in zip(rects, count_list):
# height = rect.get_height()
plt.annotate(
'{}'.format(count),
xy=(rect.get_x() + rect.get_width() / 2, 100),
# xy=(rect.get_x() + rect.get_width() / 2, height),
xytext=(0, 3), # 3 points vertical offset
textcoords="offset points",
ha='center', va='bottom'
)
else:
for rect in rects:
height = rect.get_height()
plt.annotate(
'{}'.format(height),
xy=(rect.get_x() + rect.get_width() / 2, 100),
# xy=(rect.get_x() + rect.get_width() / 2, height),
xytext=(0, 3), # 3 points vertical offset
textcoords="offset points",
ha='center', va='bottom'
)