本文整理汇总了Python中matplotlib.patches.Polygon.get_transform方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.get_transform方法的具体用法?Python Polygon.get_transform怎么用?Python Polygon.get_transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Polygon
的用法示例。
在下文中一共展示了Polygon.get_transform方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BoundaryClick
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import get_transform [as 别名]
#.........这里部分代码省略.........
self.x.append(event.xdata)
self.y.append(event.ydata)
self.beta.append(0)
self._line.set_data(self.x, self.y)
self._background = self._canvas.copy_from_bbox(self._ax.bbox)
self._ax.draw_artist(self._line)
self._canvas.blit(self._ax.bbox)
def _draw_callback(self, event):
self._background = self._canvas.copy_from_bbox(self._ax.bbox)
self._ax.draw_artist(self._poly)
self._ax.draw_artist(self._pline)
self._ax.draw_artist(self._mline)
self._ax.draw_artist(self._zline)
self._ax.draw_artist(self._sline)
self._ax.draw_artist(self._line)
self._canvas.blit(self._ax.bbox)
def _poly_changed(self, poly):
'this method is called whenever the polygon object is called'
# only copy the artist props to the line (except visibility)
vis = self._line.get_visible()
Artist.update_from(self._line, poly)
self._line.set_visible(vis) # don't use the poly visibility state
def _get_ind_under_point(self, event):
'get the index of the vertex under point if within epsilon tolerance'
try:
x, y = zip(*self._poly.xy)
# display coords
xt, yt = self._poly.get_transform().numerix_x_y(x, y)
d = sqrt((xt-event.x)**2 + (yt-event.y)**2)
indseq = nonzero(equal(d, amin(d)))
ind = indseq[0]
if d[ind]>=self._epsilon:
ind = None
return ind
except:
# display coords
xy = asarray(self._poly.xy)
xyt = self._poly.get_transform().transform(xy)
xt, yt = xyt[:, 0], xyt[:, 1]
d = sqrt((xt-event.x)**2 + (yt-event.y)**2)
indseq = nonzero(equal(d, amin(d)))[0]
ind = indseq[0]
if d[ind]>=self._epsilon:
ind = None
return ind
def _button_press_callback(self, event):
'whenever a mouse button is pressed'
# if not self._showverts: return
if event.inaxes==None: return
if event.button != 1: return
self._ind = self._get_ind_under_point(event)
def _button_release_callback(self, event):
'whenever a mouse button is released'
# if not self._showverts: return
示例2: MaskDrawer
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import get_transform [as 别名]
class MaskDrawer(object):
"""An interactive polygon mask drawer on an image.
Parameters
----------
ax : matplotlib plot axis
Inpimg : 2d numpy array
Input image to overlay for drawing mask
Mask : Boolean numpy array same size of inpimg
A Mask which will be used as initial mask and updated upon confirmation
max_ds : float
Max pixel distance to count as a vertex hit.
PolyAtStart : List of vertices
A list of square vertices to draw the initial polygon
Key-bindings
------------
't' : toggle vertex markers on and off. When vertex markers are on,
you can move them, delete them
'd' : delete the vertex under point
'i' : insert a vertex at point. You must be within max_ds of the
line connecting two existing vertices
'n' : Invert the region selected by polynomial for masking
'c' : Confirm the polygon and update the mask
"""
showverts = True
epsilon = 5 # max pixel distance to count as a vertex hit
def __init__(self, ax, Inpimg, Mask, max_ds=10,PolyAtStart = [(50,50),(100,50),(100,100),(50,100)]):
self.showverts = True
self.max_ds = max_ds
self.Mask = Mask
self.img = Inpimg
self.maskinvert = False
# imshow the image
self.imgplot = ax.imshow(np.ma.filled(np.ma.array(self.img,mask=self.Mask,fill_value=np.nan)), cmap=cm.gray)
self.poly = Polygon(PolyAtStart, animated=True,
fc='y', ec='none', alpha=0.5)
ax.add_patch(self.poly)
ax.set_clip_on(False)
ax.set_title("Click and drag a point to move it; "
"'i' to insert; 'd' to delete.\n"
"'n' to invert the region for masking, 'c' to confirm & apply the mask.")
self.ax = ax
x, y = zip(*self.poly.xy)
self.line = Line2D(x, y, color='none', marker='o', mfc='r',
alpha=0.7, animated=True)
# self._update_line()
self.ax.add_line(self.line)
self.poly.add_callback(self.poly_changed)
self._ind = None # the active vert
canvas = self.poly.figure.canvas
canvas.mpl_connect('draw_event', self.draw_callback)
canvas.mpl_connect('button_press_event', self.button_press_callback)
canvas.mpl_connect('button_release_event', self.button_release_callback)
canvas.mpl_connect('key_press_event', self.key_press_callback)
canvas.mpl_connect('motion_notify_event', self.motion_notify_callback)
self.canvas = canvas
def draw_callback(self, event):
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
self.ax.draw_artist(self.poly)
self.ax.draw_artist(self.line)
self.canvas.blit(self.ax.bbox)
def poly_changed(self, poly):
'this method is called whenever the polygon object is called'
# only copy the artist props to the line (except visibility)
vis = self.line.get_visible()
Artist.update_from(self.line, poly)
self.line.set_visible(vis) # don't use the poly visibility state
def get_ind_under_point(self, event):
'get the index of the vertex under point if within epsilon tolerance'
# display coords
xy = np.asarray(self.poly.xy)
xyt = self.poly.get_transform().transform(xy)
xt, yt = xyt[:, 0], xyt[:, 1]
d = np.sqrt((xt-event.x)**2 + (yt-event.y)**2)
indseq = np.nonzero(np.equal(d, np.amin(d)))[0]
ind = indseq[0]
if d[ind]>=self.epsilon:
ind = None
return ind
def button_press_callback(self, event):
'whenever a mouse button is pressed'
if not self.showverts: return
if event.inaxes==None: return
if event.button != 1: return
self._ind = self.get_ind_under_point(event)
#.........这里部分代码省略.........
示例3: NDViewer
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import get_transform [as 别名]
#.........这里部分代码省略.........
# so to avoid 2 start
self.clearArtistSelection()
return
if event.inaxes is None: return
self.lasso = Lasso(event.inaxes, (event.xdata, event.ydata), self.stopLasso)
# acquire a lock on the widget drawing
self.canvas.widgetlock(self.lasso)
def stopLasso(self, verts):
self.actualSelection = points_inside_poly(np.dot( self.data, self.projection ), verts)
self.canvas.widgetlock.release(self.lasso)
del self.lasso
self.selection_changed.emit()
def pressContour(self, event):
if event.inaxes==None: return
if event.button != 1: return
# new contour
if self.poly is None:
self.poly = Polygon( [[event.xdata , event.ydata]] , animated=False , alpha = .3 , color = 'g')
self.ax.add_patch(self.poly)
self.line, = self.ax.plot([event.xdata] , [event.ydata] ,
color = 'g',
linewidth = 2 ,
marker = 'o' ,
markerfacecolor='g',
animated=False)
self.redraw()
return
# event near a point
xy = np.asarray(self.poly.xy)
xyt = self.poly.get_transform().transform(xy)
xt, yt = xyt[:, 0], xyt[:, 1]
d = np.sqrt((xt-event.x)**2 + (yt-event.y)**2)
indseq = np.nonzero(np.equal(d, np.amin(d)))[0]
self._ind = indseq[0]
if d[self._ind]>=self.epsilon:
self._ind = None
# new point
if self._ind is None:
self.poly.xy = np.array( list(self.poly.xy) + [[event.xdata , event.ydata]])
self.line.set_xdata( np.array(list(self.line.get_xdata()) + [ event.xdata]) )
self.line.set_ydata( np.array(list(self.line.get_ydata()) + [ event.ydata]) )
self.redraw()
self.actualSelection = points_inside_poly(np.dot( self.data, self.projection ), self.poly.xy)
self.selection_changed.emit()
def releaseContour(self , event):
if event.button != 1: return
self._ind = None
def motionContour(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
self.poly.xy[self._ind] = x,y
self.line.set_data(zip(*self.poly.xy))
self.redraw()
self.actualSelection = points_inside_poly(np.dot( self.data, self.projection ), self.poly.xy)
self.selection_changed.emit()
def redrawSelection(self):
if self.selectionLine is not None:
if self.selectionLine in self.ax.lines:
self.ax.lines.remove(self.selectionLine)
if np.sum(self.actualSelection)>1:
# for big selection only subset are shown
sel = np.zeros(self.data.shape[0], dtype = bool)
for c in self.all_labels:
ind = self.subset[c]
sel[ind] = True
sel = sel & self.actualSelection
proj = np.dot( self.data[sel, :], self.projection )
else:
# for small selection also hideen spike are shown
proj = np.dot( self.data[self.actualSelection, :], self.projection )
self.selectionLine, = self.ax.plot(proj[:,0] , proj[:,1],
linestyle = 'None',
markersize = 10,
marker = 'o' ,
markerfacecolor='m',
markeredgecolor='k',
alpha = .6,
)
self.redraw()
示例4: MaskCreator
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import get_transform [as 别名]
#.........这里部分代码省略.........
def poly_changed(self, poly):
'this method is called whenever the polygon object is called'
# only copy the artist props to the line (except visibility)
vis = self.line.get_visible()
#Artist.update_from(self.line, poly)
self.line.set_visible(vis) # don't use the poly visibility state
def draw_callback(self, event):
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
self.ax.draw_artist(self.poly)
self.ax.draw_artist(self.line)
self.canvas.blit(self.ax.bbox)
def button_press_callback(self, event):
'whenever a mouse button is pressed'
ignore = not self.showverts or event.inaxes is None or event.button != 1
if ignore:
return
self._ind = self.get_ind_under_cursor(event)
def button_release_callback(self, event):
'whenever a mouse button is released'
ignore = not self.showverts or event.button != 1
if ignore:
return
self._ind = None
def key_press_callback(self, event):
'whenever a key is pressed'
if not event.inaxes:
return
if event.key=='t':
self.showverts = not self.showverts
self.line.set_visible(self.showverts)
if not self.showverts:
self._ind = None
elif event.key=='d':
ind = self.get_ind_under_cursor(event)
if ind is None:
return
if ind == 0 or ind == self.last_vert_ind:
print "Cannot delete root node"
return
self.poly.xy = [tup for i,tup in enumerate(self.poly.xy)
if i!=ind]
self._update_line()
elif event.key=='i':
xys = self.poly.get_transform().transform(self.poly.xy)
p = event.x, event.y # cursor coords
for i in range(len(xys)-1):
s0 = xys[i]
s1 = xys[i+1]
d = dist_point_to_segment(p, s0, s1)
if d <= self.max_ds:
self.poly.xy = np.array(
list(self.poly.xy[:i+1]) +
[(event.xdata, event.ydata)] +
list(self.poly.xy[i+1:]))
self._update_line()
break
self.canvas.draw()
def motion_notify_callback(self, event):
'on mouse movement'
ignore = (not self.showverts or event.inaxes is None or
event.button != 1 or self._ind is None)
if ignore:
return
x,y = event.xdata, event.ydata
if self._ind == 0 or self._ind == self.last_vert_ind:
self.poly.xy[0] = x,y
self.poly.xy[self.last_vert_ind] = x,y
else:
self.poly.xy[self._ind] = x,y
self._update_line()
self.canvas.restore_region(self.background)
self.ax.draw_artist(self.poly)
self.ax.draw_artist(self.line)
self.canvas.blit(self.ax.bbox)
def _update_line(self):
# save verts because polygon gets deleted when figure is closed
self.verts = self.poly.xy
self.last_vert_ind = len(self.poly.xy) - 1
self.line.set_data(zip(*self.poly.xy))
def get_ind_under_cursor(self, event):
'get the index of the vertex under cursor if within max_ds tolerance'
# display coords
xy = np.asarray(self.poly.xy)
xyt = self.poly.get_transform().transform(xy)
xt, yt = xyt[:, 0], xyt[:, 1]
d = np.sqrt((xt - event.x)**2 + (yt - event.y)**2)
indseq = np.nonzero(np.equal(d, np.amin(d)))[0]
ind = indseq[0]
if d[ind] >= self.max_ds:
ind = None
return ind
示例5: MaskCreator
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import get_transform [as 别名]
#.........这里部分代码省略.........
self.canvas.restore_region(self.background)
self.ax.draw_artist(self.poly)
self.ax.draw_artist(self.line)
self.canvas.blit(self.ax.bbox)
def move_rectangle(self,event):
selectedX, selectedY = (self.poly.xy[1])
beforeX, beforeY = (self.poly.xy[0])
afterX, afterY = (self.poly.xy[2])
acrossX, acrossY = (self.poly.xy[3])
listX = [selectedX, beforeX, afterX, acrossX]
listY = [selectedY, beforeY, afterY, acrossY]
maxX = max(listX)
maxY = max(listY)
minX = min(listX)
minY = min(listY)
x, y = event.xdata, event.ydata
if x < minX or x> maxX or y<minY or y>maxY:
return
# Change selected
self.poly.xy[1] = selectedX+(x-self.mouseX), selectedY+(y-self.mouseY)
# Change before vert
self.poly.xy[0] = beforeX+(x-self.mouseX), beforeY+(y-self.mouseY)
self.poly.xy[self.last_vert_ind] = beforeX+(x-self.mouseX), beforeY+(y-self.mouseY)
# Change after vert
self.poly.xy[2] = afterX+(x-self.mouseX), afterY+(y-self.mouseY)
#Change across vert
self.poly.xy[3] = acrossX+(x-self.mouseX), acrossY+(y-self.mouseY)
def calculate_move(self,event):
indBefore = self._ind-1
if(indBefore < 0):
indBefore = len(self.poly.xy)-2
indAfter = (self._ind+1)%4
selectedX, selectedY = (self.poly.xy[self._ind])
beforeX, beforeY = (self.poly.xy[indBefore])
afterX, afterY = (self.poly.xy[indAfter])
changeBefore = -1
keepX, changeY = -1, -1
changeAfter = -1
changeX, keepY = -1, -1
if beforeX != selectedX:
changeBefore = indBefore
keepX, changeY = self.poly.xy[indBefore]
changeAfter = indAfter
changeX, keepY = self.poly.xy[indAfter]
else:
changeBefore = indAfter
keepX, changeY = self.poly.xy[indAfter]
changeAfter = indBefore
changeX, keepY = self.poly.xy[indBefore]
x, y = event.xdata, event.ydata
# Change selected
if self._ind == 0 or self._ind == self.last_vert_ind:
self.poly.xy[0] = x, y
self.poly.xy[self.last_vert_ind] = x, y
else:
self.poly.xy[self._ind] = x, y
# Change vert
if changeBefore == 0 or changeBefore == self.last_vert_ind:
self.poly.xy[0] = keepX, y
self.poly.xy[self.last_vert_ind] = keepX, y
else:
self.poly.xy[changeBefore] = keepX, y
# Change horiz
if changeAfter == 0 or changeAfter == self.last_vert_ind:
self.poly.xy[0] = x, keepY
self.poly.xy[self.last_vert_ind] = x, keepY
else:
self.poly.xy[changeAfter] = x, keepY
def _update_line(self):
# save verts because polygon gets deleted when figure is closed
self.verts = self.poly.xy
self.last_vert_ind = len(self.poly.xy) - 1
self.line.set_data(zip(*self.poly.xy))
def get_ind_under_cursor(self, event):
'get the index of the vertex under cursor if within max_ds tolerance'
# display coords
xy = np.asarray(self.poly.xy)
xyt = self.poly.get_transform().transform(xy)
xt, yt = xyt[:, 0], xyt[:, 1]
d = np.sqrt((xt - event.x) ** 2 + (yt - event.y) ** 2)
indseq = np.nonzero(np.equal(d, np.amin(d)))[0]
ind = indseq[0]
if d[ind] >= self.max_ds:
ind = None
return ind
示例6: PolygonInteractor
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import get_transform [as 别名]
class PolygonInteractor(QtCore.QObject):
"""
Polygon Interactor
Parameters
----------
axtmp : matplotlib axis
matplotlib axis
pntxy :
"""
showverts = True
epsilon = 5 # max pixel distance to count as a vertex hit
polyi_changed = QtCore.pyqtSignal(list)
def __init__(self, axtmp, pntxy):
QtCore.QObject.__init__(self)
self.ax = axtmp
self.poly = Polygon([(1, 1)], animated=True)
self.ax.add_patch(self.poly)
self.canvas = self.poly.figure.canvas
self.poly.set_alpha(0.5)
self.pntxy = pntxy
self.ishist = True
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
xtmp, ytmp = list(zip(*self.poly.xy))
self.line = Line2D(xtmp, ytmp, marker='o', markerfacecolor='r',
color='y', animated=True)
self.ax.add_line(self.line)
self.poly.add_callback(self.poly_changed)
self._ind = None # the active vert
self.canvas.mpl_connect('button_press_event',
self.button_press_callback)
self.canvas.mpl_connect('button_release_event',
self.button_release_callback)
self.canvas.mpl_connect('motion_notify_event',
self.motion_notify_callback)
def draw_callback(self):
""" Draw callback """
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
QtWidgets.QApplication.processEvents()
self.canvas.restore_region(self.background)
self.ax.draw_artist(self.poly)
self.ax.draw_artist(self.line)
self.canvas.update()
def new_poly(self, npoly):
""" New Polygon """
self.poly.set_xy(npoly)
self.line.set_data(list(zip(*self.poly.xy)))
self.canvas.draw()
self.update_plots()
def poly_changed(self, poly):
""" Changed Polygon """
# this method is called whenever the polygon object is called
# only copy the artist props to the line (except visibility)
vis = self.line.get_visible()
Artist.update_from(self.line, poly)
self.line.set_visible(vis) # don't use the poly visibility state
def get_ind_under_point(self, event):
"""get the index of vertex under point if within epsilon tolerance"""
# display coords
xytmp = np.asarray(self.poly.xy)
xyt = self.poly.get_transform().transform(xytmp)
xtt, ytt = xyt[:, 0], xyt[:, 1]
dtt = np.sqrt((xtt - event.x) ** 2 + (ytt - event.y) ** 2)
indseq = np.nonzero(np.equal(dtt, np.amin(dtt)))[0]
ind = indseq[0]
if dtt[ind] >= self.epsilon:
ind = None
return ind
def button_press_callback(self, event):
"""whenever a mouse button is pressed"""
if event.inaxes is None:
return
if event.button != 1:
return
self._ind = self.get_ind_under_point(event)
if self._ind is None:
xys = self.poly.get_transform().transform(self.poly.xy)
ptmp = event.x, event.y # display coords
if len(xys) == 1:
self.poly.xy = np.array(
[(event.xdata, event.ydata)] +
[(event.xdata, event.ydata)])
#.........这里部分代码省略.........
示例7: PolyClick
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import get_transform [as 别名]
class PolyClick(object):
"""
p = PolyClick() # Start interactive polygon generator, or
p = PolyClick(verts, ax=gca()) # Initialize polygon based on verts, or
p = PolyClick(x, y, ax=gca()) # Initialize polygon based on x and y, or
p = PolyClick('verts.pickle', ax=gca()) # Load in verts from pickle file
If verts or (x, y) are not given, an interactive polygon creation session is
started. Verticies are orange. Switch to editing mode by hitting return. This
changes the vertecies to black. The points may be moved with the mouse, or
modified with the key commands listed below. Current data are always
available in bry.x, bry.y and bry.verts.
Key commands:
enter : switch to grid editing mode
t : toggle visibility of verticies
d : delete a vertex
i : insert a vertex at a point on the polygon line
Methods:
p.dump(bry_file='bry.pickle)
Write the current boundary informtion (bry.verts) to a cPickle
file bry_file.
p.load(bry_file='bry.pickle)
Read in boundary informtion (verts) from the cPickle file bry_file.
Attributes:
p.x, p.y : The x and y locations of the polygon verticies.
p.verts : The verticies of the polygon (equiv. to zip(x, y))
p.area : the area of the polygon. Positive for a counterclockwise path,
negative for a clockwise path.
p.centroid : the (x, y) location of the polygon centroid.
"""
_showverts = True
_epsilon = 5 # max pixel distance to count as a vertex hit
def _init_boundary_interactor(self):
"""Send polyclick thread to boundary interactor"""
# Get rid old mpl connections.
self._ax.figure.canvas.mpl_disconnect(self._key_id)
self._ax.figure.canvas.mpl_disconnect(self._click_id)
# Shade the selected region in a polygon
self._poly = Polygon(self.verts, alpha=0.2, fc='k', animated=True)
self._ax.add_patch(self._poly)
# modify the line properties
self._line.set_markerfacecolor('k')
# get the canvas and connect the callback events
cid = self._poly.add_callback(self._poly_changed)
self._ind = None # the active vert
self._canvas.mpl_connect('draw_event', self._draw_callback)
self._canvas.mpl_connect('button_press_event', self._button_press_callback)
self._canvas.mpl_connect('key_press_event', self._key_press_callback)
self._canvas.mpl_connect('button_release_event', self._button_release_callback)
self._canvas.mpl_connect('motion_notify_event', self._motion_notify_callback)
def _draw_callback(self, event):
self._background = self._canvas.copy_from_bbox(self._ax.bbox)
self._ax.draw_artist(self._poly)
self._ax.draw_artist(self._line)
self._canvas.blit(self._ax.bbox)
def _poly_changed(self, poly):
'this method is called whenever the polygon object is called'
# only copy the artist props to the line (except visibility)
vis = self._line.get_visible()
Artist.update_from(self._line, poly)
self._line.set_visible(vis) # don't use the poly visibility state
def _get_ind_under_point(self, event):
'get the index of the vertex under point if within epsilon tolerance'
try:
x, y = zip(*self._poly.xy)
# display coords
xt, yt = self._poly.get_transform().numerix_x_y(x, y)
d = sqrt((xt-event.x)**2 + (yt-event.y)**2)
indseq = nonzero(equal(d, amin(d)))
ind = indseq[0]
if d[ind]>=self._epsilon:
ind = None
return ind
except:
#.........这里部分代码省略.........
示例8: NDViewer
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import get_transform [as 别名]
#.........这里部分代码省略.........
self.actualSelection, = where(verts.contains_points(dot( self.data, self.projection )))
#~ self.canvas.draw()
self.canvas.widgetlock.release(self.lasso)
#~ print self.canvas.artists
del self.lasso
#~ print 'lasso deleted'
#~ self.redraw()
self.emit(SIGNAL('selectionChanged'))
def pressContour(self, event):
if event.inaxes==None: return
if event.button != 1: return
# new contour
if self.poly is None:
self.poly = Polygon( [(event.xdata , event.ydata)] , animated=False , alpha = .3 , color = 'g')
self.ax.add_patch(self.poly)
self.line, = self.ax.plot([event.xdata] , [event.ydata] ,
color = 'g',
linewidth = 2 ,
marker = 'o' ,
markerfacecolor='g',
animated=False)
#~ self.canvas.draw()
self.redraw()
return
# event near a point
xy = asarray(self.poly.xy)
xyt = self.poly.get_transform().transform(xy)
xt, yt = xyt[:, 0], xyt[:, 1]
print '#######'
d = sqrt((xt-event.x)**2 + (yt-event.y)**2)
indseq = nonzero(equal(d, amin(d)))[0]
self._ind = indseq[0]
if d[self._ind]>=self.epsilon:
self._ind = None
self.a=list(numpy.copy(self.poly.xy))
for i,j in enumerate(self.a):
self.a[i]=tuple(j)
# new point
if self._ind is None:
b=float(event.xdata)
c=float(event.ydata)
d=(b,c)
e=[d]
#self.a=numpy.append(self.a,e)
self.a.extend(e)
self.line.set_xdata( list(self.line.get_xdata()) + [ event.xdata] )
self.line.set_ydata( list(self.line.get_ydata()) + [ event.ydata] )
#~ self.canvas.draw()
self.redraw()
#self.poly.xy=a
print self.a, type(self.a)
if self.a != None:
test=Path(self.a)
self.actualSelection, = where(test.contains_points(dot( self.data, self.projection )))