-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatches.py
More file actions
36 lines (28 loc) · 946 Bytes
/
Copy pathPatches.py
File metadata and controls
36 lines (28 loc) · 946 Bytes
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
#Matplotlib Bar Chart:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
N = 5
men_means = (54.74, 42.35, 67.37, 58.24, 30.25)
men_std= (4, 3, 4, 1, 5)
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
fig, ax = plt.subplots()
rects1 = ax.bar(ind, men_means, width, color='r', yerr=men_std)
# add some text for labels, title and axes ticks
plt.ylabel('Scores')
plt.xlabel('Velocity')
plt.title('Scores by Velocity')
red_patch = mpatches.Patch(color='red', label='Men')
plt.legend(handles=[red_patch])
def autolabel(rects):
"""
Attach a text label above each bar displaying its height
"""
for rect in rects:
height = rect.get_height()
ax.text(rect.get_x() + rect.get_width()/2., 1.05*height,
'%d' % int(height),
ha='center', va='bottom')
autolabel(rects1)
plt.show()