diff --git a/examples/lines_bars_and_markers/bar_stacked.py b/examples/lines_bars_and_markers/bar_stacked.py index 7ef827cc46b1..719cb52c6b2c 100644 --- a/examples/lines_bars_and_markers/bar_stacked.py +++ b/examples/lines_bars_and_markers/bar_stacked.py @@ -21,14 +21,16 @@ ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars: can also be len(x) sequence -plt.bar(ind, men_means, width, yerr=men_std, label='Men') -plt.bar(ind, women_means, width, yerr=women_std, bottom=men_means, - label='Women') - -plt.ylabel('Scores') -plt.title('Scores by group and gender') -plt.xticks(ind, ('G1', 'G2', 'G3', 'G4', 'G5')) -plt.yticks(np.arange(0, 81, 10)) -plt.legend() +fig, ax = plt.subplots() + +ax.bar(ind, men_means, width, yerr=men_std, label='Men') +ax.bar(ind, women_means, width, yerr=women_std, bottom=men_means, + label='Women') + +ax.set_ylabel('Scores') +ax.set_title('Scores by group and gender') +ax.set_xticks(ind, ('G1', 'G2', 'G3', 'G4', 'G5')) +ax.set_yticks(np.arange(0, 81, 10)) +ax.legend() plt.show()