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

Skip to content

Commit 6341cc2

Browse files
committed
STY: pep8 fixup
1 parent 8458613 commit 6341cc2

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

examples/pylab_examples/barchart_demo2.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
'Push Ups']
2222
testMeta = dict(zip(testNames, ['laps', 'sec', 'min:sec', 'sec', '']))
2323

24+
2425
def attach_ordinal(num):
2526
"""helper function to add ordinal string to integers
2627
@@ -37,6 +38,7 @@ def attach_ordinal(num):
3738
return v + 'th'
3839
return v + suffixes[v[-1]]
3940

41+
4042
def format_score(scr, test):
4143
"""
4244
Build up the score labels for the right Y-axis by first
@@ -52,6 +54,7 @@ def format_score(scr, test):
5254
else:
5355
return scr
5456

57+
5558
def format_ycursor(y):
5659
y = int(y)
5760
if y < 0 or y >= len(testNames):
@@ -77,7 +80,8 @@ def plot_student_results(student, scores, cohort_size):
7780

7881
ax1.set_xlim([0, 100])
7982
ax1.xaxis.set_major_locator(MaxNLocator(11))
80-
ax1.xaxis.grid(True, linestyle='--', which='major', color='grey', alpha=.25)
83+
ax1.xaxis.grid(True, linestyle='--', which='major',
84+
color='grey', alpha=.25)
8185

8286
# Plot a solid vertical gridline to highlight the median position
8387
ax1.axvline(50, color='grey', alpha=0.25)
@@ -102,10 +106,10 @@ def plot_student_results(student, scores, cohort_size):
102106

103107
ax2.set_ylabel('Test Scores')
104108

105-
ax2.set_xlabel(
106-
'Percentile Ranking Across {grade} Grade {gender}s'.format(
107-
grade=attach_ordinal(student.grade),
108-
gender=student.gender.title()))
109+
ax2.set_xlabel(('Percentile Ranking Across '
110+
'{grade} Grade {gender}s').format(
111+
grade=attach_ordinal(student.grade),
112+
gender=student.gender.title()))
109113

110114
rect_labels = []
111115
# Lastly, write in the ranking inside each bar to aid in interpretation
@@ -116,13 +120,18 @@ def plot_student_results(student, scores, cohort_size):
116120
width = int(rect.get_width())
117121

118122
rankStr = attach_ordinal(width)
119-
if (width < 5): # The bars aren't wide enough to print the ranking inside
120-
xloc = width + 1 # Shift the text to the right side of the right edge
121-
clr = 'black' # Black against white background
123+
# The bars aren't wide enough to print the ranking inside
124+
if (width < 5):
125+
# Shift the text to the right side of the right edge
126+
xloc = width + 1
127+
# Black against white background
128+
clr = 'black'
122129
align = 'left'
123130
else:
124-
xloc = 0.98*width # Shift the text to the left side of the right edge
125-
clr = 'white' # White on magenta
131+
# Shift the text to the left side of the right edge
132+
xloc = 0.98*width
133+
# White on magenta
134+
clr = 'white'
126135
align = 'right'
127136

128137
# Center the text vertically in the bar
@@ -146,7 +155,8 @@ def plot_student_results(student, scores, cohort_size):
146155
scores = dict(zip(testNames,
147156
(Score(v, p) for v, p in
148157
zip(['7', '48', '12:52', '17', '14'],
149-
np.round(np.random.uniform(0, 1, len(testNames))*100, 0)))))
158+
np.round(np.random.uniform(0, 1,
159+
len(testNames))*100, 0)))))
150160
cohort_size = 62 # The number of other 2nd grade boys
151161

152162
arts = plot_student_results(student, scores, cohort_size)

0 commit comments

Comments
 (0)