Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a8cf29a

Browse filesBrowse files
committed
Fix Stacked bar graph example
1 parent cf45de8 commit a8cf29a
Copy full SHA for a8cf29a

File tree

Expand file treeCollapse file tree

1 file changed

+4
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-7
lines changed
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
=================
3-
Stacked Bar Graph
3+
Stacked bar chart
44
=================
55
66
This is an example of creating a stacked bar plot with error bars
@@ -13,24 +13,21 @@
1313
import matplotlib.pyplot as plt
1414

1515

16-
N = 5
16+
labels = ['G1', 'G2', 'G3', 'G4', 'G5']
1717
men_means = [20, 35, 30, 35, 27]
1818
women_means = [25, 32, 34, 20, 25]
1919
men_std = [2, 3, 4, 1, 2]
2020
women_std = [3, 5, 2, 3, 3]
21-
ind = np.arange(N) # the x locations for the groups
2221
width = 0.35 # the width of the bars: can also be len(x) sequence
2322

2423
fig, ax = plt.subplots()
2524

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,
25+
ax.bar(labels, men_means, width, yerr=men_std, label='Men')
26+
ax.bar(labels, women_means, width, yerr=women_std, bottom=men_means,
2827
label='Women')
2928

3029
ax.set_ylabel('Scores')
3130
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))
3431
ax.legend()
3532

3633
plt.show()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.