Skip to content

[examples] fix pep8 error classes e231 and e241 #3714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/color/named_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
xf_line = w * (col + 0.25)
xi_text = w * (col + 0.3)

ax.text(xi_text, y, name, fontsize=(h * 0.8),
ax.text(xi_text, y, name, fontsize=(h * 0.8),
horizontalalignment='left',
verticalalignment='center')

Expand Down
4 changes: 2 additions & 2 deletions examples/event_handling/data_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ def __init__(self):

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

def onpress(self, event):
if self.lastind is None: return
if event.key not in ('n', 'p'): return
if event.key=='n': inc = 1
else: inc = -1
else: inc = -1

self.lastind += inc
self.lastind = np.clip(self.lastind, 0, len(xs)-1)
Expand Down
2 changes: 1 addition & 1 deletion examples/event_handling/lasso_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def onpress(self, event):

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

ax = plt.axes(xlim=(0,1), ylim=(0,1), autoscale_on=False)
ax = plt.axes(xlim=(0, 1), ylim=(0, 1), autoscale_on=False)
lman = LassoManager(ax, data)

plt.show()
10 changes: 5 additions & 5 deletions examples/event_handling/path_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, pathpatch):

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

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

self._ind = None # the active vert

Expand Down Expand Up @@ -117,11 +117,11 @@ def motion_notify_callback(self, event):
if self._ind is None: return
if event.inaxes is None: return
if event.button != 1: return
x,y = event.xdata, event.ydata
x, y = event.xdata, event.ydata

vertices = self.pathpatch.get_path().vertices

vertices[self._ind] = x,y
vertices[self._ind] = x, y
self.line.set_data(zip(*vertices))

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

interactor = PathInteractor(patch)
ax.set_title('drag vertices to update path')
ax.set_xlim(-3,4)
ax.set_ylim(-3,4)
ax.set_xlim(-3, 4)
ax.set_ylim(-3, 4)

plt.show()
12 changes: 6 additions & 6 deletions examples/event_handling/pick_event_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def pick_handler(event):
from numpy.random import rand

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

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

def onpick4(event):
artist = event.artist
Expand Down
2 changes: 1 addition & 1 deletion examples/event_handling/pick_event_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def onpick(event):

figi = plt.figure()
for subplotnum, dataind in enumerate(event.ind):
ax = figi.add_subplot(N,1,subplotnum+1)
ax = figi.add_subplot(N, 1, subplotnum+1)
ax.plot(X[dataind])
ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
transform=ax.transAxes, va='top')
Expand Down
42 changes: 21 additions & 21 deletions examples/event_handling/pipong.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


class Pad(object):
def __init__(self, disp,x,y,type='l'):
def __init__(self, disp, x, y, type='l'):
self.disp = disp
self.x = x
self.y = y
Expand All @@ -49,7 +49,7 @@ def __init__(self, disp,x,y,type='l'):
self.signy = -1.0

def contains(self, loc):
return self.disp.get_bbox().contains(loc.x,loc.y)
return self.disp.get_bbox().contains(loc.x, loc.y)


class Puck(object):
Expand All @@ -59,7 +59,7 @@ def __init__(self, disp, pad, field):
self.field = field
self._reset(pad)

def _reset(self,pad):
def _reset(self, pad):
self.x = pad.x + pad.xoffset
if pad.y < 0:
self.y = pad.y + pad.yoffset
Expand All @@ -71,7 +71,7 @@ def _reset(self,pad):
self._slower()
self._slower()

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

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

self.canvas = self.ax.figure.canvas
self.background = None
Expand All @@ -145,15 +145,15 @@ def __init__(self, ax):
self.inst = True # show instructions from the beginning
self.background = None
self.pads = []
self.pads.append(Pad(pA,0,padAy))
self.pads.append(Pad(pB,padBx,padBy,'r'))
self.pads.append(Pad(pA, 0, padAy))
self.pads.append(Pad(pB, padBx, padBy, 'r'))
self.pucks =[]
self.i = self.ax.annotate(instructions,(.5,0.5),
self.i = self.ax.annotate(instructions, (.5, 0.5),
name='monospace',
verticalalignment='center',
horizontalalignment='center',
multialignment='left',
textcoords='axes fraction',animated=True)
textcoords='axes fraction', animated=True)
self.canvas.mpl_connect('key_press_event', self.key_press)

def draw(self, evt):
Expand Down Expand Up @@ -196,12 +196,12 @@ def draw(self, evt):
self.leg = self.ax.get_legend()
#self.leg.draw_frame(False) #don't draw the legend border
self.leg.get_frame().set_alpha(.2)
plt.setp(self.leg.get_texts(),fontweight='bold',fontsize='xx-large')
plt.setp(self.leg.get_texts(), fontweight='bold', fontsize='xx-large')
self.leg.get_frame().set_facecolor('0.2')
self.background = None
self.ax.figure.canvas.draw()
return True
puck.disp.set_offsets([puck.x,puck.y])
puck.disp.set_offsets([puck.x, puck.y])
self.ax.draw_artist(puck.disp)

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

def key_press(self,event):
def key_press(self, event):
if event.key == '3':
self.res *= 5.0
if event.key == '4':
Expand All @@ -240,7 +240,7 @@ def key_press(self,event):
self.pads[1].y = -1

if event.key == 'a':
self.pucks.append(Puck(self.puckdisp,self.pads[randint(2)],self.ax.bbox))
self.pucks.append(Puck(self.puckdisp, self.pads[randint(2)], self.ax.bbox))
if event.key == 'A' and len(self.pucks):
self.pucks.pop()
if event.key == ' ' and len(self.pucks):
Expand Down
10 changes: 5 additions & 5 deletions examples/event_handling/poly_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def key_press_callback(self, event):
elif event.key=='d':
ind = self.get_ind_under_point(event)
if ind is not None:
self.poly.xy = [tup for i,tup in enumerate(self.poly.xy) if i!=ind]
self.poly.xy = [tup for i, tup in enumerate(self.poly.xy) if i!=ind]
self.line.set_data(zip(*self.poly.xy))
elif event.key=='i':
xys = self.poly.get_transform().transform(self.poly.xy)
Expand All @@ -127,9 +127,9 @@ def motion_notify_callback(self, event):
if self._ind is None: return
if event.inaxes is None: return
if event.button != 1: return
x,y = event.xdata, event.ydata
x, y = event.xdata, event.ydata

self.poly.xy[self._ind] = x,y
self.poly.xy[self._ind] = x, y
self.line.set_data(zip(*self.poly.xy))

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

#ax.add_line(p.line)
ax.set_title('Click and drag a point to move it')
ax.set_xlim((-2,2))
ax.set_ylim((-2,2))
ax.set_xlim((-2, 2))
ax.set_ylim((-2, 2))
plt.show()
2 changes: 1 addition & 1 deletion examples/event_handling/pong_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

def start_anim(event):
# gobject.idle_add(animation.draw,animation)
gobject.timeout_add(10,animation.draw,animation)
gobject.timeout_add(10, animation.draw, animation)
canvas.mpl_disconnect(start_anim.cid)

animation = pipong.Game(ax)
Expand Down
4 changes: 2 additions & 2 deletions examples/event_handling/viewlims.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, h=500, w=500, niter=50, radius=2., power=2):

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

# Get the range for the new area
xstart,ystart,xdelta,ydelta = ax.viewLim.bounds
xstart, ystart, xdelta, ydelta = ax.viewLim.bounds
xend = xstart + xdelta
yend = ystart + ydelta

Expand Down
12 changes: 6 additions & 6 deletions examples/event_handling/zoom_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
figsrc = figure()
figzoom = figure()

axsrc = figsrc.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False)
axzoom = figzoom.add_subplot(111, xlim=(0.45,0.55), ylim=(0.4,.6),
axsrc = figsrc.add_subplot(111, xlim=(0, 1), ylim=(0, 1), autoscale_on=False)
axzoom = figzoom.add_subplot(111, xlim=(0.45, 0.55), ylim=(0.4, .6),
autoscale_on=False)
axsrc.set_title('Click to zoom')
axzoom.set_title('zoom window')
x,y,s,c = numpy.random.rand(4,200)
x, y, s, c = numpy.random.rand(4, 200)
s *= 200


axsrc.scatter(x,y,s,c)
axzoom.scatter(x,y,s,c)
axsrc.scatter(x, y, s, c)
axzoom.scatter(x, y, s, c)


def onpress(event):
if event.button!=1: return
x,y = event.xdata, event.ydata
x, y = event.xdata, event.ydata
axzoom.set_xlim(x-0.1, x+0.1)
axzoom.set_ylim(y-0.1, y+0.1)
figzoom.canvas.draw()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@

# Create a 2x2 table of plots
fig = plt.figure(figsize=[8.0, 7.5])
ax = plt.subplot(2,2,1)
ax = plt.subplot(2, 2, 1)
ax.imshow(big_im, interpolation='none')
ax = plt.subplot(2,2,2)
ax = plt.subplot(2, 2, 2)
ax.imshow(big_im, interpolation='nearest')
ax = plt.subplot(2,2,3)
ax = plt.subplot(2, 2, 3)
ax.imshow(small_im, interpolation='none')
ax = plt.subplot(2,2,4)
ax = plt.subplot(2, 2, 4)
ax.imshow(small_im, interpolation='nearest')
plt.subplots_adjust(left=0.24, wspace=0.2, hspace=0.1, \
bottom=0.05, top=0.86)
Expand Down
22 changes: 11 additions & 11 deletions examples/misc/contour_manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
import matplotlib.cm as cm

# Contour lines for each level are a list/tuple of polygons.
lines0 = [[[0,0],[0,4]]]
lines1 = [[[2,0],[1,2],[1,3]]]
lines2 = [[[3,0],[3,2]], [[3,3],[3,4]]] # Note two lines.
lines0 = [[[0, 0], [0, 4]]]
lines1 = [[[2, 0], [1, 2], [1, 3]]]
lines2 = [[[3, 0], [3, 2]], [[3, 3], [3, 4]]] # Note two lines.

# Filled contours between two levels are also a list/tuple of polygons.
# Points can be ordered clockwise or anticlockwise.
filled01 = [[[0,0],[0,4],[1,3],[1,2],[2,0]]]
filled12 = [[[2,0],[3,0],[3,2],[1,3],[1,2]], # Note two polygons.
[[1,4],[3,4],[3,3]]]
filled01 = [[[0, 0], [0, 4], [1, 3], [1, 2], [2, 0]]]
filled12 = [[[2, 0], [3, 0], [3, 2], [1, 3], [1, 2]], # Note two polygons.
[[1, 4], [3, 4], [3, 3]]]


plt.figure()

# Filled contours using filled=True.
cs = ContourSet(plt.gca(), [0,1,2], [filled01, filled12], filled=True, cmap=cm.bone)
cs = ContourSet(plt.gca(), [0, 1, 2], [filled01, filled12], filled=True, cmap=cm.bone)
cbar = plt.colorbar(cs)

# Contour lines (non-filled).
lines = ContourSet(plt.gca(), [0,1,2], [lines0, lines1, lines2], cmap=cm.cool,
lines = ContourSet(plt.gca(), [0, 1, 2], [lines0, lines1, lines2], cmap=cm.cool,
linewidths=3)
cbar.add_lines(lines)

Expand All @@ -38,9 +38,9 @@
# Here a code type of 1 is a MOVETO, and 2 is a LINETO.

plt.figure()
filled01 = [[[0,0],[3,0],[3,3],[0,3],[1,1],[1,2],[2,2],[2,1]]]
kinds01 = [[1,2,2,2,1,2,2,2]]
cs = ContourSet(plt.gca(), [0,1], [filled01], [kinds01], filled=True)
filled01 = [[[0, 0], [3, 0], [3, 3], [0, 3], [1, 1], [1, 2], [2, 2], [2, 1]]]
kinds01 = [[1, 2, 2, 2, 1, 2, 2, 2]]
cs = ContourSet(plt.gca(), [0, 1], [filled01], [kinds01], filled=True)
cbar = plt.colorbar(cs)

plt.axis([-0.5, 3.5, -0.5, 3.5])
Expand Down
Loading