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!