|
21 | 21 | ind = np.arange(N) # the x locations for the groups
|
22 | 22 | width = 0.35 # the width of the bars: can also be len(x) sequence
|
23 | 23 |
|
24 |
| -plt.bar(ind, men_means, width, yerr=men_std, label='Men') |
25 |
| -plt.bar(ind, women_means, width, yerr=women_std, bottom=men_means, |
26 |
| - label='Women') |
27 |
| - |
28 |
| -plt.ylabel('Scores') |
29 |
| -plt.title('Scores by group and gender') |
30 |
| -plt.xticks(ind, ('G1', 'G2', 'G3', 'G4', 'G5')) |
31 |
| -plt.yticks(np.arange(0, 81, 10)) |
32 |
| -plt.legend() |
| 24 | +fig, ax = plt.subplots() |
| 25 | + |
| 26 | +ax.bar(ind, men_means, width, yerr=men_std, label='Men') |
| 27 | +ax.bar(ind, women_means, width, yerr=women_std, bottom=men_means, |
| 28 | + label='Women') |
| 29 | + |
| 30 | +ax.set_ylabel('Scores') |
| 31 | +ax.set_title('Scores by group and gender') |
| 32 | +ax.set_xticks(ind, ('G1', 'G2', 'G3', 'G4', 'G5')) |
| 33 | +ax.set_yticks(np.arange(0, 81, 10)) |
| 34 | +ax.legend() |
33 | 35 |
|
34 | 36 | plt.show()
|
0 commit comments