8000 PEP8 moved examples · matplotlib/matplotlib@82adb61 · GitHub
[go: up one dir, main page]

Skip to content

Commit 82adb61

Browse files
committed
PEP8 moved examples
1 parent 559deb1 commit 82adb61

File tree

5 files changed

+25
-23
lines changed

5 files changed

+25
-23
lines changed

examples/color/color_by_yvalue.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
"""
2-
===============
3-
Color By Yvalue
4-
===============
2+
================
3+
Color By y-value
4+
================
55
66
Use masked arrays to plot a line with different colors by y-value.
77
"""
88
import numpy as np
99
import matplotlib.pyplot as plt
1010

1111
t = np.arange(0.0, 2.0, 0.01)
12-
s = np.sin(2*np.pi*t)
12+
s = np.sin(2 * np.pi * t)
1313

1414
upper = 0.77
1515
lower = -0.77
@@ -19,5 +19,6 @@
1919
slower = np.ma.masked_where(s > lower, s)
2020
smiddle = np.ma.masked_where(np.logical_or(s < lower, s > upper), s)
2121

22-
plt.plot(t, smiddle, t, slower, t, supper)
22+
fig, ax = plt.subplots()
23+
ax.plot(t, smiddle, t, slower, t, supper)
2324
plt.show()

examples/color/color_demo.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
import matplotlib.pyplot as plt
2323
import numpy as np
2424

25-
plt.subplot(111, facecolor='darkslategray')
26-
#subplot(111, facecolor='#ababab')
25+
fig, ax = plt.subplots(facecolor='darkslategray')
2726
t = np.arange(0.0, 2.0, 0.01)
28-
s = np.sin(2*np.pi*t)
29-
plt.plot(t, s, 'C1')
30-
plt.xlabel('time (s)', color='C1')
31-
plt.ylabel('voltage (mV)', color='0.5') # grayscale color
32-
plt.title('About as silly as it gets, folks', color='#afeeee')
27+
s = np.sin(2 * np.pi * t)
28+
ax.plot(t, s, 'C1')
29+
ax.set_xlabel('time (s)', color='C1')
30+
ax.set_ylabel('voltage (mV)', color='0.5') # grayscale color
31+
ax.set_title('About as silly as it gets, folks', color='#afeeee')
32+
3333
plt.show()

examples/images_contours_and_fields/contour_corner_mask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Data to plot.
1313
x, y = np.meshgrid(np.arange(7), np.arange(10))
14-
z = np.sin(0.5*x)*np.cos(0.52*y)
14+
z = np.sin(0.5 * x) * np.cos(0.52 * y)
1515

1616
# Mask various z values.
1717
mask = np.zeros_like(z, dtype=np.bool)
@@ -24,7 +24,7 @@
2424

2525
corner_masks = [False, True]
2626
for i, corner_mask in enumerate(corner_masks):
27-
plt.subplot(1, 2, i+1)
27+
plt.subplot(1, 2, i + 1)
2828
cs = plt.contourf(x, y, z, corner_mask=corner_mask)
2929
plt.contour(cs, colors='k')
3030
plt.title('corner_mask = {0}'.format(corner_mask))

examples/lines_bars_and_markers/barchart_demo2.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ def plot_student_results(student, scores, cohort_size):
137137
align = 'left'
138138
else:
139139
# Shift the text to the left side of the right edge
140-
xloc = 0.98*width
140+
xloc = 0.98 * width
141141
# White on magenta
142142
clr = 'white'
143143
align = 'right'
144144

145145
# Center the text vertically in the bar
146-
yloc = rect.get_y() + rect.get_height()/2.0
146+
yloc = rect.get_y() + rect.get_height() / 2.0
147147
label = ax1.text(xloc, yloc, rankStr, horizontalalignment=align,
148148
verticalalignment='center', color=clr, weight='bold',
149149
clip_on=True)
@@ -159,12 +159,13 @@ def plot_student_results(student, scores, cohort_size):
159159
'perc_labels': rect_labels,
160160
'cohort_label': cohort_label}
161161

162+
162163
student = Student('Johnny Doe', 2, 'boy')
163164
scores = dict(zip(testNames,
164165
(Score(v, p) for v, p in
165166
zip(['7', '48', '12:52', '17', '14'],
166167
np.round(np.random.uniform(0, 1,
167-
len(testNames))*100, 0)))))
168+
len(testNames)) * 100, 0)))))
168169
cohort_size = 62 # The number of other 2nd grade boys
169170

170171
arts = plot_student_results(student, scores, cohort_size)

examples/pylab_examples/barb_demo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
x = np.linspace(-5, 5, 5)
1212
X, Y = np.meshgrid(x, x)
13-
U, V = 12*X, 12*Y
13+
U, V = 12 * X, 12 * Y
1414

1515
data = [(-1.5, .5, -6, -6),
1616
(1, -1, -46, 46),
@@ -27,29 +27,29 @@
2727
ax.barbs(X, Y, U, V)
2828

2929
# Arbitrary set of vectors, make them longer and change the pivot point
30-
#(point around which they're rotated) to be the middle
30+
# (point around which they're rotated) to be the middle
3131
ax = plt.subplot(2, 2, 2)
3232
ax.barbs(data['x'], data['y'], data['u'], data['v'], length=8, pivot='middle')
3333

3434
# Showing colormapping with uniform grid. Fill the circle for an empty barb,
3535
# don't round the values, and change some of the size parameters
3636
ax = plt.subplot(2, 2, 3)
37-
ax.barbs(X, Y, U, V, np.sqrt(U*U + V*V), fill_empty=True, rounding=False,
37+
ax.barbs(X, Y, U, V, np.sqrt(U * U + V * V), fill_empty=True, rounding=False,
3838
sizes=dict(emptybarb=0.25, spacing=0.2, height=0.3))
3939

4040
# Change colors as well as the increments for parts of the barbs
4141
ax = plt.subplot(2, 2, 4)
4242
ax.barbs(data['x'], data['y'], data['u'], data['v'], flagcolor='r',
43-
barbcolor=['b', 'g'], barb_increments=dict(half=10, full=20, flag=100),
44-
flip_barb=True)
43+
barbcolor=['b', 'g'],
44+
barb_increments=dict(half=10, full=20, flag=100), flip_barb=True)
4545

4646
# Masked arrays are also supported
4747
masked_u = np.ma.masked_array(data['u'])
4848
masked_u[4] = 1000 # Bad value that should not be plotted when masked
4949
masked_u[4] = np.ma.masked
5050

5151
# Identical plot to panel 2 in the first figure, but with the point at
52-
#(0.5, 0.25) missing (masked)
52+
# (0.5, 0.25) missing (masked)
5353
fig2 = plt.figure()
5454
ax = fig2.add_subplot(1, 1, 1)
5555
ax.barbs(data['x'], data['y'], masked_u, data['v'], length=8, pivot='middle')

0 commit comments

Comments
 (0)
0