Skip to content

Commit 894f3df

Browse files
committed
Merge pull request matplotlib#3201 from matplotlib/revert-3181-pep8examplesapi
Revert "[examples/api] autopep8 + use np.radians/np.degree where appropr...
2 parents ff42dcb + f1e608d commit 894f3df

37 files changed

+331
-355
lines changed

Diff for: examples/api/agg_oo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
fig = Figure()
1010
canvas = FigureCanvas(fig)
1111
ax = fig.add_subplot(111)
12-
ax.plot([1, 2, 3])
12+
ax.plot([1,2,3])
1313
ax.set_title('hi mom')
1414
ax.grid(True)
1515
ax.set_xlabel('time')

Diff for: examples/api/barchart_demo.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
N = 5
88
menMeans = (20, 35, 30, 35, 27)
9-
menStd = (2, 3, 4, 1, 2)
9+
menStd = (2, 3, 4, 1, 2)
1010

1111
ind = np.arange(N) # the x locations for the groups
1212
width = 0.35 # the width of the bars
@@ -15,26 +15,23 @@
1515
rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)
1616

1717
womenMeans = (25, 32, 34, 20, 25)
18-
womenStd = (3, 5, 2, 3, 3)
19-
rects2 = ax.bar(ind + width, womenMeans, width, color='y', yerr=womenStd)
18+
womenStd = (3, 5, 2, 3, 3)
19+
rects2 = ax.bar(ind+width, womenMeans, width, color='y', yerr=womenStd)
2020

2121
# add some text for labels, title and axes ticks
2222
ax.set_ylabel('Scores')
2323
ax.set_title('Scores by group and gender')
24-
ax.set_xticks(ind + width)
25-
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))
26-
27-
ax.legend((rects1[0], rects2[0]), ('Men', 'Women'))
24+
ax.set_xticks(ind+width)
25+
ax.set_xticklabels( ('G1', 'G2', 'G3', 'G4', 'G5') )
2826

27+
ax.legend( (rects1[0], rects2[0]), ('Men', 'Women') )
2928

3029
def autolabel(rects):
3130
# attach some text labels
3231
for rect in rects:
3332
height = rect.get_height()
34-
ax.text(
35-
rect.get_x() + rect.get_width() /
36-
2., 1.05 * height, '%d' % int(height),
37-
ha='center', va='bottom')
33+
ax.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height),
34+
ha='center', va='bottom')
3835

3936
autolabel(rects1)
4037
autolabel(rects2)

Diff for: examples/api/bbox_intersect.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
color = 'r'
1515
else:
1616
color = 'b'
17-
plt.plot(vertices[:, 0], vertices[:, 1], color=color)
17+
plt.plot(vertices[:,0], vertices[:,1], color=color)
1818

1919
plt.show()

Diff for: examples/api/collections_demo.py

+17-16
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727

2828
# Make some spirals
2929
r = np.array(range(nverts))
30-
theta = np.array(range(nverts)) * (2 * np.pi) / (nverts - 1)
30+
theta = np.array(range(nverts)) * (2*np.pi)/(nverts-1)
3131
xx = r * np.sin(theta)
3232
yy = r * np.cos(theta)
33-
spiral = list(zip(xx, yy))
33+
spiral = list(zip(xx,yy))
3434

3535
# Make some offsets
3636
rs = np.random.RandomState([12345678])
@@ -39,16 +39,15 @@
3939
xyo = list(zip(xo, yo))
4040

4141
# Make a list of colors cycling through the rgbcmyk series.
42-
colors = [colorConverter.to_rgba(c)
43-
for c in ('r', 'g', 'b', 'c', 'y', 'm', 'k')]
42+
colors = [colorConverter.to_rgba(c) for c in ('r','g','b','c','y','m','k')]
4443

45-
fig, axes = plt.subplots(2, 2)
46-
((ax1, ax2), (ax3, ax4)) = axes # unpack the axes
44+
fig, axes = plt.subplots(2,2)
45+
((ax1, ax2), (ax3, ax4)) = axes # unpack the axes
4746

4847

4948
col = collections.LineCollection([spiral], offsets=xyo,
50-
transOffset=ax1.transData)
51-
trans = fig.dpi_scale_trans + transforms.Affine2D().scale(1.0 / 72.0)
49+
transOffset=ax1.transData)
50+
trans = fig.dpi_scale_trans + transforms.Affine2D().scale(1.0/72.0)
5251
col.set_transform(trans) # the points to pixels transform
5352
# Note: the first argument to the collection initializer
5453
# must be a list of sequences of x,y tuples; we have only
@@ -72,8 +71,8 @@
7271

7372
# The same data as above, but fill the curves.
7473
col = collections.PolyCollection([spiral], offsets=xyo,
75-
transOffset=ax2.transData)
76-
trans = transforms.Affine2D().scale(fig.dpi / 72.0)
74+
transOffset=ax2.transData)
75+
trans = transforms.Affine2D().scale(fig.dpi/72.0)
7776
col.set_transform(trans) # the points to pixels transform
7877
ax2.add_collection(col, autolim=True)
7978
col.set_color(colors)
@@ -85,9 +84,9 @@
8584
# 7-sided regular polygons
8685

8786
col = collections.RegularPolyCollection(7,
88-
sizes=np.fabs(xx) * 10.0, offsets=xyo,
87+
sizes = np.fabs(xx)*10.0, offsets=xyo,
8988
transOffset=ax3.transData)
90-
trans = transforms.Affine2D().scale(fig.dpi / 72.0)
89+
trans = transforms.Affine2D().scale(fig.dpi/72.0)
9190
col.set_transform(trans) # the points to pixels transform
9291
ax3.add_collection(col, autolim=True)
9392
col.set_color(colors)
@@ -103,13 +102,13 @@
103102
ncurves = 20
104103
offs = (0.1, 0.0)
105104

106-
yy = np.linspace(0, 2 * np.pi, nverts)
105+
yy = np.linspace(0, 2*np.pi, nverts)
107106
ym = np.amax(yy)
108-
xx = (0.2 + (ym - yy) / ym) ** 2 * np.cos(yy - 0.4) * 0.5
107+
xx = (0.2 + (ym-yy)/ym)**2 * np.cos(yy-0.4) * 0.5
109108
segs = []
110109
for i in range(ncurves):
111-
xxx = xx + 0.02 * rs.randn(nverts)
112-
curve = list(zip(xxx, yy * 100))
110+
xxx = xx + 0.02*rs.randn(nverts)
111+
curve = list(zip(xxx, yy*100))
113112
segs.append(curve)
114113

115114
col = collections.LineCollection(segs, offsets=offs)
@@ -124,3 +123,5 @@
124123

125124

126125
plt.show()
126+
127+

Diff for: examples/api/colorbar_only.py

+22-22
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import matplotlib as mpl
77

88
# Make a figure and axes with dimensions as desired.
9-
fig = pyplot.figure(figsize=(8, 3))
9+
fig = pyplot.figure(figsize=(8,3))
1010
ax1 = fig.add_axes([0.05, 0.80, 0.9, 0.15])
1111
ax2 = fig.add_axes([0.05, 0.475, 0.9, 0.15])
1212
ax3 = fig.add_axes([0.05, 0.15, 0.9, 0.15])
@@ -22,8 +22,8 @@
2222
# following gives a basic continuous colorbar with ticks
2323
# and labels.
2424
cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cmap,
25-
norm=norm,
26-
orientation='horizontal')
25+
norm=norm,
26+
orientation='horizontal')
2727
cb1.set_label('Some Units')
2828

2929
# The second example illustrates the use of a ListedColormap, a
@@ -39,36 +39,36 @@
3939
bounds = [1, 2, 4, 7, 8]
4040
norm = mpl.colors.BoundaryNorm(bounds, cmap.N)
4141
cb2 = mpl.colorbar.ColorbarBase(ax2, cmap=cmap,
42-
norm=norm,
43-
# to use 'extend', you must
44-
# specify two extra boundaries:
45-
boundaries=[0] + bounds + [13],
46-
extend='both',
47-
ticks=bounds, # optional
48-
spacing='proportional',
49-
orientation='horizontal')
42+
norm=norm,
43+
# to use 'extend', you must
44+
# specify two extra boundaries:
45+
boundaries=[0]+bounds+[13],
46+
extend='both',
47+
ticks=bounds, # optional
48+
spacing='proportional',
49+
orientation='horizontal')
5050
cb2.set_label('Discrete intervals, some other units')
5151

5252
# The third example illustrates the use of custom length colorbar
5353
# extensions, used on a colorbar with discrete intervals.
5454
cmap = mpl.colors.ListedColormap([[0., .4, 1.], [0., .8, 1.],
55-
[1., .8, 0.], [1., .4, 0.]])
55+
[1., .8, 0.], [1., .4, 0.]])
5656
cmap.set_over((1., 0., 0.))
5757
cmap.set_under((0., 0., 1.))
5858

5959
bounds = [-1., -.5, 0., .5, 1.]
6060
norm = mpl.colors.BoundaryNorm(bounds, cmap.N)
6161
cb3 = mpl.colorbar.ColorbarBase(ax3, cmap=cmap,
62-
norm=norm,
63-
boundaries=[-10] + bounds + [10],
64-
extend='both',
65-
# Make the length of each extension
66-
# the same as the length of the
67-
# interior colors:
68-
extendfrac='auto',
69-
ticks=bounds,
70-
spacing='uniform',
71-
orientation='horizontal')
62+
norm=norm,
63+
boundaries=[-10]+bounds+[10],
64+
extend='both',
65+
# Make the length of each extension
66+
# the same as the length of the
67+
# interior colors:
68+
extendfrac='auto',
69+
ticks=bounds,
70+
spacing='uniform',
71+
orientation='horizontal')
7272
cb3.set_label('Custom extension lengths, some other units')
7373

7474
pyplot.show()

Diff for: examples/api/compound_path.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
vertices = []
1313
codes = []
1414

15-
codes = [Path.MOVETO] + [Path.LINETO] * 3 + [Path.CLOSEPOLY]
16-
vertices = [(1, 1), (1, 2), (2, 2), (2, 1), (0, 0)]
15+
codes = [Path.MOVETO] + [Path.LINETO]*3 + [Path.CLOSEPOLY]
16+
vertices = [(1,1), (1,2), (2, 2), (2, 1), (0,0)]
1717

18-
codes += [Path.MOVETO] + [Path.LINETO] * 2 + [Path.CLOSEPOLY]
19-
vertices += [(4, 4), (5, 5), (5, 4), (0, 0)]
18+
codes += [Path.MOVETO] + [Path.LINETO]*2 + [Path.CLOSEPOLY]
19+
vertices += [(4,4), (5,5), (5, 4), (0,0)]
2020

2121
vertices = np.array(vertices, float)
2222
path = Path(vertices, codes)

0 commit comments

Comments
 (0)