From 39da3c3ac54250ca0ff42e4648b99e5f8096d96e Mon Sep 17 00:00:00 2001 From: Chen Karako Date: Thu, 26 May 2016 20:31:49 -0400 Subject: [PATCH] Cleaned up: added docstrings and switched mixcase variables to comply with PEP 8 --- examples/api/barchart_demo.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/api/barchart_demo.py b/examples/api/barchart_demo.py index be6b6e24fbb4..e651b77538f4 100644 --- a/examples/api/barchart_demo.py +++ b/examples/api/barchart_demo.py @@ -1,20 +1,22 @@ -# a bar plot with errorbars +""" +A bar plot with errorbars and height labels on individual bars +""" import numpy as np import matplotlib.pyplot as plt N = 5 -menMeans = (20, 35, 30, 35, 27) -menStd = (2, 3, 4, 1, 2) +men_means = (20, 35, 30, 35, 27) +men_std = (2, 3, 4, 1, 2) ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars fig, ax = plt.subplots() -rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd) +rects1 = ax.bar(ind, men_means, width, color='r', yerr=men_std) -womenMeans = (25, 32, 34, 20, 25) -womenStd = (3, 5, 2, 3, 3) -rects2 = ax.bar(ind + width, womenMeans, width, color='y', yerr=womenStd) +women_means = (25, 32, 34, 20, 25) +women_std = (3, 5, 2, 3, 3) +rects2 = ax.bar(ind + width, women_means, width, color='y', yerr=women_std) # add some text for labels, title and axes ticks ax.set_ylabel('Scores') @@ -26,7 +28,9 @@ def autolabel(rects): - # attach some text labels + """ + Attach a text label above each bar displaying its height + """ for rect in rects: height = rect.get_height() ax.text(rect.get_x() + rect.get_width()/2., 1.05*height,