def pick(event): global data global X global Y global numpy_container if event.key == 'q': if len(X) == 0: return if not numpy_container: data = VectorDataSet(X) else: data = PyVectorDataSet(numpy.array(X)) data.attachLabels(Labels(Y)) X = [] Y = [] print 'done creating data. close this window and use the decisionSurface function' pylab.disconnect(binding_id) if event.key == '1' or event.key == '2': if event.inaxes is not None: print 'data coords', event.xdata, event.ydata X.append([event.xdata, event.ydata]) Y.append(event.key) pylab.plot([event.xdata], [event.ydata], plotStr[int(event.key) - 1]) pylab.draw()
def pick(event) : global data global X global Y global numpy_container if event.key == 'q' : if len(X) == 0 : return if not numpy_container : data = VectorDataSet(X) else : data = PyVectorDataSet(numpy.array(X)) data.attachLabels(Labels(Y)) X = [] Y = [] print 'done creating data. close this window and use the decisionSurface function' pylab.disconnect(binding_id) if event.key =='1' or event.key == '2' : if event.inaxes is not None: print 'data coords', event.xdata, event.ydata X.append([event.xdata, event.ydata]) Y.append(event.key) pylab.plot([event.xdata], [event.ydata], plotStr[int(event.key) - 1]) pylab.draw()