Exemplo n.º 1
0
def onpick1(event):
    if isinstance(event.artist, Line2D):
        thisline = event.artist
        xdata = thisline.get_xdata()
        ydata = thisline.get_ydata()
        ind = event.ind
        print 'onpick1 line:', zip(nx.take(xdata, ind), nx.take(ydata, ind))
    elif isinstance(event.artist, Rectangle):
        patch = event.artist
        print 'onpick1 patch:', patch.get_verts()
    elif isinstance(event.artist, Text):
        text = event.artist
        print 'onpick1 text:', text.get_text()
Exemplo n.º 2
0
def onpick1(event):
    if isinstance(event.artist, Line2D):
        thisline = event.artist
        xdata = thisline.get_xdata()
        ydata = thisline.get_ydata()
        ind = event.ind
        print 'onpick1 line:', zip(nx.take(xdata, ind), nx.take(ydata, ind))
    elif isinstance(event.artist, Rectangle):
        patch = event.artist
        print 'onpick1 patch:', patch.get_verts()
    elif isinstance(event.artist, Text):
        text = event.artist
        print 'onpick1 text:', text.get_text()
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 5
0
 def onpick3(event):
     ind = event.ind
     print 'onpick3 scatter:', ind, nx.take(x, ind), nx.take(y, ind)