GUI setup for scatter plot, taking samples
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 14 Apr 2019
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 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!