Skip to content

Commit b97a02b

Browse files
committed
Merge pull request matplotlib#3714 from thisch/pep8fix_e231_e241
[examples] fix pep8 error classes e231 and e241
2 parents 18e3330 + 903db2c commit b97a02b

File tree

203 files changed

+885
-885
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+885
-885
lines changed

examples/color/named_colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
xf_line = w * (col + 0.25)
6161
xi_text = w * (col + 0.3)
6262

63-
ax.text(xi_text, y, name, fontsize=(h * 0.8),
63+
ax.text(xi_text, y, name, fontsize=(h * 0.8),
6464
horizontalalignment='left',
6565
verticalalignment='center')
6666

examples/event_handling/data_browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ def __init__(self):
1313

1414
self.text = ax.text(0.05, 0.95, 'selected: none',
1515
transform=ax.transAxes, va='top')
16-
self.selected, = ax.plot([xs[0]], [ys[0]], 'o', ms=12, alpha=0.4,
16+
self.selected, = ax.plot([xs[0]], [ys[0]], 'o', ms=12, alpha=0.4,
1717
color='yellow', visible=False)
1818

1919
def onpress(self, event):
2020
if self.lastind is None: return
2121
if event.key not in ('n', 'p'): return
2222
if event.key=='n': inc = 1
23-
else: inc = -1
23+
else: inc = -1
2424

2525
self.lastind += inc
2626
self.lastind = np.clip(self.lastind, 0, len(xs)-1)

examples/event_handling/lasso_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def onpress(self, event):
7373

7474
data = [Datum(*xy) for xy in rand(100, 2)]
7575

76-
ax = plt.axes(xlim=(0,1), ylim=(0,1), autoscale_on=False)
76+
ax = plt.axes(xlim=(0, 1), ylim=(0, 1), autoscale_on=False)
7777
lman = LassoManager(ax, data)
7878

7979
plt.show()

examples/event_handling/path_editor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(self, pathpatch):
4949

5050
x, y = zip(*self.pathpatch.get_path().vertices)
5151

52-
self.line, = ax.plot(x,y,marker='o', markerfacecolor='r', animated=True)
52+
self.line, = ax.plot(x, y, marker='o', markerfacecolor='r', animated=True)
5353

5454
self._ind = None # the active vert
5555

@@ -117,11 +117,11 @@ def motion_notify_callback(self, event):
117117
if self._ind is None: return
118118
if event.inaxes is None: return
119119
if event.button != 1: return
120-
x,y = event.xdata, event.ydata
120+
x, y = event.xdata, event.ydata
121121

122122
vertices = self.pathpatch.get_path().vertices
123123

124-
vertices[self._ind] = x,y
124+
vertices[self._ind] = x, y
125125
self.line.set_data(zip(*vertices))
126126

127127
self.canvas.restore_region(self.background)
@@ -132,7 +132,7 @@ def motion_notify_callback(self, event):
132132

133133
interactor = PathInteractor(patch)
134134
ax.set_title('drag vertices to update path')
135-
ax.set_xlim(-3,4)
136-
ax.set_ylim(-3,4)
135+
ax.set_xlim(-3, 4)
136+
ax.set_ylim(-3, 4)
137137

138138
plt.show()

examples/event_handling/pick_event_demo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def pick_handler(event):
7474
from numpy.random import rand
7575

7676
if 1: # simple picking, lines, rectangles and text
77-
fig, (ax1, ax2) = plt.subplots(2,1)
77+
fig, (ax1, ax2) = plt.subplots(2, 1)
7878
ax1.set_title('click on points, rectangles or text', picker=True)
7979
ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red'))
8080
line, = ax1.plot(rand(100), 'o', picker=5) # 5 points tolerance
@@ -155,11 +155,11 @@ def onpick3(event):
155155

156156
if 1: # picking images (matplotlib.image.AxesImage)
157157
fig, ax = plt.subplots()
158-
im1 = ax.imshow(rand(10,5), extent=(1,2,1,2), picker=True)
159-
im2 = ax.imshow(rand(5,10), extent=(3,4,1,2), picker=True)
160-
im3 = ax.imshow(rand(20,25), extent=(1,2,3,4), picker=True)
161-
im4 = ax.imshow(rand(30,12), extent=(3,4,3,4), picker=True)
162-
ax.axis([0,5,0,5])
158+
im1 = ax.imshow(rand(10, 5), extent=(1, 2, 1, 2), picker=True)
159+
im2 = ax.imshow(rand(5, 10), extent=(3, 4, 1, 2), picker=True)
160+
im3 = ax.imshow(rand(20, 25), extent=(1, 2, 3, 4), picker=True)
161+
im4 = ax.imshow(rand(30, 12), extent=(3, 4, 3, 4), picker=True)
162+
ax.axis([0, 5, 0, 5])
163163

164164
def onpick4(event):
165165
artist = event.artist

examples/event_handling/pick_event_demo2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def onpick(event):
2525

2626
figi = plt.figure()
2727
for subplotnum, dataind in enumerate(event.ind):
28-
ax = figi.add_subplot(N,1,subplotnum+1)
28+
ax = figi.add_subplot(N, 1, subplotnum+1)
2929
ax.plot(X[dataind])
3030
ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
3131
transform=ax.transAxes, va='top')

examples/event_handling/pipong.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
class Pad(object):
33-
def __init__(self, disp,x,y,type='l'):
33+
def __init__(self, disp, x, y, type='l'):
3434
self.disp = disp
3535
self.x = x
3636
self.y = y
@@ -49,7 +49,7 @@ def __init__(self, disp,x,y,type='l'):
4949
self.signy = -1.0
5050

5151
def contains(self, loc):
52-
return self.disp.get_bbox().contains(loc.x,loc.y)
52+
return self.disp.get_bbox().contains(loc.x, loc.y)
5353

5454

5555
class Puck(object):
@@ -59,7 +59,7 @@ def __init__(self, disp, pad, field):
5959
self.field = field
6060
self._reset(pad)
6161

62-
def _reset(self,pad):
62+
def _reset(self, pad):
6363
self.x = pad.x + pad.xoffset
6464
if pad.y < 0:
6565
self.y = pad.y + pad.yoffset
@@ -71,7 +71,7 @@ def _reset(self,pad):
7171
self._slower()
7272
self._slower()
7373

74-
def update(self,pads):
74+
def update(self, pads):
7575
self.x += self.vx
7676
self.y += self.vy
7777
for pad in pads:
@@ -124,17 +124,17 @@ def __init__(self, ax):
124124
padAx = padBx= .50
125125
padAy = padBy= .30
126126
padBx+=6.3
127-
pA, = self.ax.barh(padAy,.2, height=.3,color='k', alpha=.5, edgecolor='b',lw=2,label="Player B", animated=True)
128-
pB, = self.ax.barh(padBy,.2, height=.3, left=padBx, color='k',alpha=.5, edgecolor='r',lw=2,label="Player A",animated=True)
127+
pA, = self.ax.barh(padAy, .2, height=.3, color='k', alpha=.5, edgecolor='b', lw=2, label="Player B", animated=True)
128+
pB, = self.ax.barh(padBy, .2, height=.3, left=padBx, color='k', alpha=.5, edgecolor='r', lw=2, label="Player A", animated=True)
129129

130130
# distractors
131-
self.x = np.arange(0,2.22*np.pi,0.01)
132-
self.line, = self.ax.plot(self.x, np.sin(self.x),"r", animated=True, lw=4)
133-
self.line2, = self.ax.plot(self.x, np.cos(self.x),"g", animated=True, lw=4)
134-
self.line3, = self.ax.plot(self.x, np.cos(self.x),"g", animated=True, lw=4)
135-
self.line4, = self.ax.plot(self.x, np.cos(self.x),"r", animated=True, lw=4)
136-
self.centerline,= self.ax.plot([3.5,3.5], [1,-1],'k',alpha=.5, animated=True, lw=8)
137-
self.puckdisp = self.ax.scatter([1],[1],label='_nolegend_', s=200,c='g',alpha=.9,animated=True)
131+
self.x = np.arange(0, 2.22*np.pi, 0.01)
132+
self.line, = self.ax.plot(self.x, np.sin(self.x), "r", animated=True, lw=4)
133+
self.line2, = self.ax.plot(self.x, np.cos(self.x), "g", animated=True, lw=4)
134+
self.line3, = self.ax.plot(self.x, np.cos(self.x), "g", animated=True, lw=4)
135+
self.line4, = self.ax.plot(self.x, np.cos(self.x), "r", animated=True, lw=4)
136+
self.centerline, = self.ax.plot([3.5, 3.5], [1, -1], 'k', alpha=.5, animated=True, lw=8)
137+
self.puckdisp = self.ax.scatter([1], [1], label='_nolegend_', s=200, c='g', alpha=.9, animated=True)
138138

139139
self.canvas = self.ax.figure.canvas
140140
self.background = None
@@ -145,15 +145,15 @@ def __init__(self, ax):
145145
self.inst = True # show instructions from the beginning
146146
self.background = None
147147
self.pads = []
148-
self.pads.append(Pad(pA,0,padAy))
149-
self.pads.append(Pad(pB,padBx,padBy,'r'))
148+
self.pads.append(Pad(pA, 0, padAy))
149+
self.pads.append(Pad(pB, padBx, padBy, 'r'))
150150
self.pucks =[]
151-
self.i = self.ax.annotate(instructions,(.5,0.5),
151+
self.i = self.ax.annotate(instructions, (.5, 0.5),
152152
name='monospace',
153153
verticalalignment='center',
154154
horizontalalignment='center',
155155
multialignment='left',
156-
textcoords='axes fraction',animated=True)
156+
textcoords='axes fraction', animated=True)
157157
self.canvas.mpl_connect('key_press_event', self.key_press)
158158

159159
def draw(self, evt):
@@ -196,12 +196,12 @@ def draw(self, evt):
196196
self.leg = self.ax.get_legend()
197197
#self.leg.draw_frame(False) #don't draw the legend border
198198
self.leg.get_frame().set_alpha(.2)
199-
plt.setp(self.leg.get_texts(),fontweight='bold',fontsize='xx-large')
199+
plt.setp(self.leg.get_texts(), fontweight='bold', fontsize='xx-large')
200200
self.leg.get_frame().set_facecolor('0.2')
201201
self.background = None
202202
self.ax.figure.canvas.draw()
203203
return True
204-
puck.disp.set_offsets([puck.x,puck.y])
204+
puck.disp.set_offsets([puck.x, puck.y])
205205
self.ax.draw_artist(puck.disp)
206206

207207
# just redraw the axes rectangle
@@ -215,7 +215,7 @@ def draw(self, evt):
215215
self.cnt += 1
216216
return True
217217

218-
def key_press(self,event):
218+
def key_press(self, event):
219219
if event.key == '3':
220220
self.res *= 5.0
221221
if event.key == '4':
@@ -240,7 +240,7 @@ def key_press(self,event):
240240
self.pads[1].y = -1
241241

242242
if event.key == 'a':
243-
self.pucks.append(Puck(self.puckdisp,self.pads[randint(2)],self.ax.bbox))
243+
self.pucks.append(Puck(self.puckdisp, self.pads[randint(2)], self.ax.bbox))
244244
if event.key == 'A' and len(self.pucks):
245245
self.pucks.pop()
246246
if event.key == ' ' and len(self.pucks):

examples/event_handling/poly_editor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def key_press_callback(self, event):
102102
elif event.key=='d':
103103
ind = self.get_ind_under_point(event)
104104
if ind is not None:
105-
self.poly.xy = [tup for i,tup in enumerate(self.poly.xy) if i!=ind]
105+
self.poly.xy = [tup for i, tup in enumerate(self.poly.xy) if i!=ind]
106106
self.line.set_data(zip(*self.poly.xy))
107107
elif event.key=='i':
108108
xys = self.poly.get_transform().transform(self.poly.xy)
@@ -127,9 +127,9 @@ def motion_notify_callback(self, event):
127127
if self._ind is None: return
128128
if event.inaxes is None: return
129129
if event.button != 1: return
130-
x,y = event.xdata, event.ydata
130+
x, y = event.xdata, event.ydata
131131

132-
self.poly.xy[self._ind] = x,y
132+
self.poly.xy[self._ind] = x, y
133133
self.line.set_data(zip(*self.poly.xy))
134134

135135
self.canvas.restore_region(self.background)
@@ -156,6 +156,6 @@ def motion_notify_callback(self, event):
156156

157157
#ax.add_line(p.line)
158158
ax.set_title('Click and drag a point to move it')
159-
ax.set_xlim((-2,2))
160-
ax.set_ylim((-2,2))
159+
ax.set_xlim((-2, 2))
160+
ax.set_ylim((-2, 2))
161161
plt.show()

examples/event_handling/pong_gtk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
def start_anim(event):
2424
# gobject.idle_add(animation.draw,animation)
25-
gobject.timeout_add(10,animation.draw,animation)
25+
gobject.timeout_add(10, animation.draw, animation)
2626
canvas.mpl_disconnect(start_anim.cid)
2727

2828
animation = pipong.Game(ax)

examples/event_handling/viewlims.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, h=500, w=500, niter=50, radius=2., power=2):
2727

2828
def __call__(self, xstart, xend, ystart, yend):
2929
self.x = np.linspace(xstart, xend, self.width)
30-
self.y = np.linspace(ystart, yend, self.height).reshape(-1,1)
30+
self.y = np.linspace(ystart, yend, self.height).reshape(-1, 1)
3131
c = self.x + 1.0j * self.y
3232
threshold_time = np.zeros((self.height, self.width))
3333
z = np.zeros(threshold_time.shape, dtype=np.complex)
@@ -47,7 +47,7 @@ def ax_update(self, ax):
4747
self.height = int(dims[2] + 0.5)
4848

4949
# Get the range for the new area
50-
xstart,ystart,xdelta,ydelta = ax.viewLim.bounds
50+
xstart, ystart, xdelta, ydelta = ax.viewLim.bounds
5151
xend = xstart + xdelta
5252
yend = ystart + ydelta
5353

0 commit comments

Comments
 (0)