![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1780060/image.png)
How to select the outliers of a scatter plot by mouse click and return the coordinates to the main function
3 ビュー (過去 30 日間)
古いコメントを表示
How to select the outliers of a scatter plot by mouse click and return the coordinates to the main function.
Here is a scatter plot composed of known points, how to select some anomalies by mouse click and return the coordinates of the anomalies to the main function?
Suppose the selected points in the graph are anomalies (3 points).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1212248/image.png)
0 件のコメント
回答 (1 件)
Suraj Kumar
2024 年 9 月 27 日
To select outliers from a scatter plot and return the coordinates of the selected points to the main function, you can follow these steps:
1. Use the ‘ginput’ function to capture the x and y coordinates of the points selected from the plot by clicking.
% Get user input for selected points
[xSelected, ySelected] = ginput;
2. Visually mark the selected points in the scatter plot to confirm them.
hold on;
scatter(xSelected, ySelected, 100, 'r', 'x'); % Mark selected points
hold off;
3. Store the coordinates in a matrix and return the matrix from the function.
selectedPoints = [xSelected, ySelected];
You may refer to the output below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1780060/image.png)
For more information on the ‘ginput’ function in MATLAB, you can check the following documentation:
Hope this helps!
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!