category data and plot selection update|

This commit is contained in:
2006-04-19 10:37:44 +00:00
parent a8937ededb
commit 1091bea0e9
3 changed files with 89 additions and 21 deletions

View File

@@ -237,9 +237,9 @@ class ScatterPlot (Plot):
self.ax = ax = fig.add_subplot(111)
self.x_dataset = project.c_p.datasets[0]
x = self.x_dataset._data
self.a = a = x[:,0]
self.b = b = x[:,1]
ax.plot(a,b,'og')
self.xaxis_data = xaxis_data = x[:,0]
self.yaxis_data = yaxis_data = x[:,1]
ax.plot(xaxis_data,yaxis_data,'og')
self.canvas = FigureCanvas(fig)
self.add(self.canvas)
rectprops = dict(facecolor='blue', edgecolor = 'black',
@@ -256,14 +256,24 @@ class ScatterPlot (Plot):
logger.log('debug', "(%3.2f, %3.2f) --> (%3.2f, %3.2f)"%(x1,y1,x2,y2))
logger.log('debug',"The button you used were:%s, %s "%(event1.button, event2.button))
# get all points within x1, y1, x2, y2
ydata = self.b
xdata = self.a
index =scipy.nonzero((xdata<x2) & (xdata>x1) & (ydata<y1) & (ydata>y2))
ydata = self.yaxis_data
xdata = self.xaxis_data
if x1>x2:
if y1<y2:
index =scipy.nonzero((xdata<x1) & (xdata>x2) & (ydata>y1) & (ydata<y2))
else:
index =scipy.nonzero((xdata<x1) & (xdata>x2) & (ydata<y1) & (ydata>y2))
else:
if y1<y2:
index =scipy.nonzero((xdata>x2) & (xdata<x1) & (ydata>y1) & (ydata<y2))
else:
index =scipy.nonzero((xdata>x2) & (xdata<x1) & (ydata<y1) & (ydata>y2))
if len(index)==0:
logger.log('debug','No points selected!')
else:
logger.log('debug','Selected:\n%s'%index)
ids = self.x_dataset.index_to_id('samples',index)
ids = self.x_dataset.extract_id_from_index('samples',index)
logger.log('debug','Selected identifiers:\n%s'%ids)
xdata_new = scipy.take(xdata,index)
ydata_new = scipy.take(ydata,index)