Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39da3c3

Browse files
committed
Cleaned up: added docstrings and switched mixcase variables to comply with PEP 8
1 parent 6f27d8b commit 39da3c3

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

examples/api/barchart_demo.py

Lines 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)