コード例 #1
0
    def callback(self, verts):
        #print 'all done', verts
        #ind = matplotlib.mlab._inside_poly_deprecated(self.xys, verts)
        ind = nx.nonzero(points_inside_poly(self.xys, verts))
        for i in range(self.Nxy):
            if i in ind:
                self.facecolors[i] = Datum.colorin
            else:
                self.facecolors[i] = Datum.colorout

        self.canvas.draw_idle()
        self.canvas.widgetlock.release(self.lasso)
        del self.lasso
コード例 #2
0
    def callback(self, verts):
        #print 'all done', verts
        #ind = matplotlib.mlab._inside_poly_deprecated(self.xys, verts)
        ind = nx.nonzero(points_inside_poly(self.xys, verts))
        for i in range(self.Nxy):
            if i in ind:
                self.facecolors[i] = Datum.colorin
            else:
                self.facecolors[i] = Datum.colorout             

        self.canvas.draw_idle()
        self.canvas.widgetlock.release(self.lasso)
        del self.lasso
コード例 #3
0
def line_picker(line, mouseevent):
    """
    find the points within a certain distance from the mouseclick in
    data coords and attach some extra attributes, pickx and picky
    which are the data points that were picked
    """
    if mouseevent.xdata is None: return False, dict()
    xdata = line.get_xdata()
    ydata = line.get_ydata()
    maxd = 0.05
    d = nx.sqrt((xdata-mouseevent.xdata)**2. + (ydata-mouseevent.ydata)**2.)

    ind = nx.nonzero(nx.less_equal(d, maxd))
    if len(ind):
        pickx = nx.take(xdata, ind)
        picky = nx.take(ydata, ind)
        props = dict(ind=ind, pickx=pickx, picky=picky)
        return True, props
    else:
        return False, dict()
コード例 #4
0
def line_picker(line, mouseevent):
    """
    find the points within a certain distance from the mouseclick in
    data coords and attach some extra attributes, pickx and picky
    which are the data points that were picked
    """
    if mouseevent.xdata is None: return False, dict()
    xdata = line.get_xdata()
    ydata = line.get_ydata()
    maxd = 0.05
    d = nx.sqrt((xdata - mouseevent.xdata)**2. +
                (ydata - mouseevent.ydata)**2.)

    ind = nx.nonzero(nx.less_equal(d, maxd))
    if len(ind):
        pickx = nx.take(xdata, ind)
        picky = nx.take(ydata, ind)
        props = dict(ind=ind, pickx=pickx, picky=picky)
        return True, props
    else:
        return False, dict()