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!