GUI setup for scatter plot, taking samples
4 次查看(过去 30 天)
显示 更早的评论
I have a scatter plot which presents the second column versus the first column of a matrix, A i.e.
scatter(A(:,1),A(:,2),'filled');
When I look at the graph, I want to choose a specific point (x,y) and find out what is the row number (i) of matrix A where
A(i,1)=x , A(i,2)=y
In other words, to find out the row number of A to which the selected point corresponds to.
Any ideas?
0 个评论
回答(1 个)
Walter Roberson
2019-4-14
call datacursormode() and provide an UpdateFcn property for it. When the user click on the graph, the function will be called, and the event parameter (second parameter) of the function call will have a Position property which gives coordinates. You can use pdist2() or similar to find the distances of the cursor to each of the points in the scatter object, and then you can output the index of that object in the form of a cell array of character vectors; the text will be displayed in the data tip.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!