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 ee74fd6

Browse filesBrowse files
committed
Merge pull request #6485 from ckarako/clean-up-barchart-example
DOC: Barchart demo example clean up [MEP 12]
1 parent c922fcc commit ee74fd6
Copy full SHA for ee74fd6

File tree

Expand file treeCollapse file tree

1 file changed

+12
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-8
lines changed

‎examples/api/barchart_demo.py

Copy file name to clipboardExpand all lines: examples/api/barchart_demo.py
+12-8Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
# a bar plot with errorbars
1+
"""
2+
A bar plot with errorbars and height labels on individual bars
3+
"""
24
import numpy as np
35
import matplotlib.pyplot as plt
46

57
N = 5
6-
menMeans = (20, 35, 30, 35, 27)
7-
menStd = (2, 3, 4, 1, 2)
8+
men_means = (20, 35, 30, 35, 27)
9+
men_std = (2, 3, 4, 1, 2)
810

911
ind = np.arange(N) # the x locations for the groups
1012
width = 0.35 # the width of the bars
1113

1214
fig, ax = plt.subplots()
13-
rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)
15+
rects1 = ax.bar(ind, men_means, width, color='r', yerr=men_std)
1416

15-
womenMeans = (25, 32, 34, 20, 25)
16-
womenStd = (3, 5, 2, 3, 3)
17-
rects2 = ax.bar(ind + width, womenMeans, width, color='y', yerr=womenStd)
17+
women_means = (25, 32, 34, 20, 25)
18+
women_std = (3, 5, 2, 3, 3)
19+
rects2 = ax.bar(ind + width, women_means, width, color='y', yerr=women_std)
1820

1921
# add some text for labels, title and axes ticks
2022
ax.set_ylabel('Scores')
@@ -26,7 +28,9 @@
2628

2729

2830
def autolabel(rects):
29-
# attach some text labels
31+
"""
32+
Attach a text label above each bar displaying its height
33+
"""
3034
for rect in rects:
3135
height = rect.get_height()
3236
ax.text(rect.get_x() + rect.get_width()/2., 1.05*height,

0 commit comments

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