Graphical data selection tool

版本 1.0.0.0 (10.2 KB) 作者: John D'Errico
A graphical tool to modify your plots and locate data points
15.4K 次下载
更新时间 2007/2/20

查看许可证

编者注: This file was a File Exchange Pick of the Week

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.

plot(rand(5,2),rand(5,2),'o')
[pind,xs,ys] = selectdata('selectionmode','lasso')
pind =
[ 3]
[2x1 double]
xs =
[ 0.099422]
[2x1 double]
ys =
[ 0.87571]
[2x1 double]

Selection with a circular brush, deleting those selected from the plot.

plot(rand(5,2),rand(5,2),'o')
[pind,xs,ys] = selectdata('sel','br','action','delete')
pind =
[3]
[4]
xs =
[0.67745]
[0.69115]
ys =
[0.76837]
[0.59464]

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-');
hold on
h2 = plot(x,ydata,'o');
[pind,xs,ys] = selectdata('sel','lasso','ignore',h1)

pind =
20
78
99
xs =
0.19
0.77
0.98
ys =
2.3639
3.2279
3.7707

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.

引用格式

John D'Errico (2024). Graphical data selection tool (https://www.mathworks.com/matlabcentral/fileexchange/13857-graphical-data-selection-tool), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2006b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Fit Postprocessing 的更多信息
标签 添加标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0

Version 3: Added the option of displaying the (x,y) coordinates of each selected point on the plot.