From 94c47e24613283f98f4d2d7b15f0c50d3c645419 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Mon, 22 Jul 2019 13:32:49 -0700 Subject: [PATCH 1/2] Update bar stacked example to directly manipulate axes. Avoid using the stateful plt interface --- examples/lines_bars_and_markers/bar_stacked.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/lines_bars_and_markers/bar_stacked.py b/examples/lines_bars_and_markers/bar_stacked.py index 7ef827cc46b1..acdbf4a2841d 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, +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') -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() +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() From 2e77a3b59f586bd6035fef629c7e4ef9c6ad4b58 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Mon, 22 Jul 2019 14:02:49 -0700 Subject: [PATCH 2/2] reindent line. --- examples/lines_bars_and_markers/bar_stacked.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/lines_bars_and_markers/bar_stacked.py b/examples/lines_bars_and_markers/bar_stacked.py index acdbf4a2841d..719cb52c6b2c 100644 --- a/examples/lines_bars_and_markers/bar_stacked.py +++ b/examples/lines_bars_and_markers/bar_stacked.py @@ -25,7 +25,7 @@ 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') + label='Women') ax.set_ylabel('Scores') ax.set_title('Scores by group and gender')