-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiplot.py
More file actions
79 lines (68 loc) · 2.1 KB
/
multiplot.py
File metadata and controls
79 lines (68 loc) · 2.1 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
# # import matplotlib.pyplot as plt
# # plt.figure(1) # the first figure
# # plt.subplot(211) # the first subplot in the first figure
# # plt.plot([1, 2, 3])
# # plt.subplot(212) # the second subplot in the first figure
# # plt.plot([4, 5, 6])
# #
# #
# # plt.figure(2) # a second figure
# # plt.plot([4, 5, 6]) # creates a subplot(111) by default
# #
# # plt.figure(1) # figure 1 current; subplot(212) still current
# # plt.subplot(211) # make subplot(211) in figure1 current
# # plt.title('Easy as 1, 2, 3') # subplot 211 title
# # plt.show()
#
# import numpy as np
# import matplotlib.pyplot as plt
# from matplotlib import style
#
# style.use('ggplot')
# # Fixing random state for reproducibility
# np.random.seed(19680801)
#
# mu, sigma = 100, 15
# x = mu + sigma * np.random.randn(10000)
#
# # the histogram of the data
# n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)
#
#
# plt.xlabel('$\sigma_i=15$')
# plt.ylabel('Probability')
# plt.title('Histogram of IQ')
# plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
# plt.axis([40, 160, 0, 0.03])
# # plt.grid(True)
# plt.show()
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
from collections import namedtuple
n_groups = 5
means_men = (20, 35, 30, 35, 27)
std_men = (2, 3, 4, 1, 2)
means_women = (25, 32, 34, 20, 25)
std_women = (3, 5, 2, 3, 3)
fig, ax = plt.subplots()
index = np.arange(n_groups)
bar_width = 0.35
opacity = 0.4
error_config = {'ecolor': '0.3'}
rects1 = ax.bar(index, means_men, bar_width,
alpha=opacity, color='b',
yerr=std_men, error_kw=error_config,
label='Men')
rects2 = ax.bar(index + bar_width, means_women, bar_width,
alpha=opacity, color='r',
yerr=std_women, error_kw=error_config,
label='Women')
ax.set_xlabel('Group')
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(index + bar_width / 2)
ax.set_xticklabels(('A', 'B', 'C', 'D', 'E'))
ax.legend()
fig.tight_layout()
plt.show()