Selectdata is a tool that allows the user to graphically select one or more points from a 2-d plot using a variety of graphical tools. You can specify a lasso tool, a paint brush of two shapes and various sizes, an expanding rectangle, or just click near a desired point.
As points are selected with the tool of choice, they become highlighted (temporarily) until the mouse button is released. Then the index of the points selected, plus their (x,y) coordinates are returned. The user has control of many aspects of the tool, including whether the selected points are to be deleted from the plot. (There are also some hidden options that I did not include in the help itself. You can find them by editing the file.)
I wrote this tool as a generic utility one could call from within a gui based modeling application. It could also be useful when called directly from the commandline to identify data points or sets of points on a plot, or to delete points (outliers) from a plot. It can be used to return the points selected or all of those that remained unselected. In my own use of this tool, I use it to identify sets of points for which I wish to modify the regression weights.
Some examples of use:
Simple selection with a lasso - I selected one point from one of the two curves, and two points from the second curve.
[pind,xs,ys] = selectdata('selectionmode','lasso')
Selection with a circular brush, deleting those selected from the plot.
[pind,xs,ys] = selectdata('sel','br','action','delete')
Plot two curves, one is data, the second a model. Allow the selection tool (the lasso) to only see the data.
x = 0:.01:1;
y = exp(x);
ydata = y + randn(size(y))/2;
h1 = plot(x,y,'r-');
h2 = plot(x,ydata,'o');
[pind,xs,ys] = selectdata('sel','lasso','ignore',h1)
Thanks to Jiro and a reviewer for some great ideas for the enhancements implemented in version 2.
Version 3 has the ability to label each selected point with its coordinates.
Please send me e-mail if you find any problems.