matlab - can I use roipoly to get data from a scatter plot?
-
26-10-2019 - |
Question
I want to select data using a polygonal shape. I understand roipoly does that for 'images'. is there something like this for scatter plots?
Solution
You can use data brushing to mark data on a scatter plot then extract it to the workspace. Look for the little brush symbol at the top of a figure window.
See Marking up graphs with Data Brushing from Matlab, and Accessing plot brushed data from the very useful Undocumented Matlab.
If you want to draw a complex polygon, you can use impoly and inpoly:
X = rand(200, 2);
scatter(X(:,1), X(:,2));
h = impoly();
% now you go and position the polygon, control returns once you've 'finsished' with it '
nodes = getPosition(h);
selected_indices = inpoly(X, nodes);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow