How do I get the brush tool to ignore points?

조회 수: 3 (최근 30일)
millercommamatt
millercommamatt 2021년 10월 19일
댓글: millercommamatt 2021년 10월 19일
Let's say I have a single figure with multiple line or scatter objects sharing the same axis.
I would like to use the brush tool to select points only from some subset of those objects. e.g. I want to use the brush tool to select the blue points and not the green points.
Can I do this?
If not, is there an alternative way to allow a user to select groups of points on a plots and use that data programatically that would disallow the selecting of certain points?

답변 (1개)

Kevin Holly
Kevin Holly 2021년 10월 19일
figure
scatter(rand(20,1),rand(20,1),'g')
hold on
scatter(rand(20,1),rand(20,1),'b')
Right Click and select "Export Brushed..."
Select data you are interested in and select "OK"
Choose variable name for the data.
  댓글 수: 1
millercommamatt
millercommamatt 2021년 10월 19일
Is there an option where the brush tool will never capture those points in the first place? I'm trying to do this without user interaction?
In thinking about this more, I realized that I could have the brush.ActionPostCallback function set the BrushData property back to all zeros for the scatter handles I don't want selected.
fh = figure();
ah1 = scatter(rand(20,1),rand(20,1),'g');
hold on
ah2 = scatter(rand(20,1),rand(20,1),'b');
bh = brush(fh);
bh.ActionPostCallback = @ignoreGreen;
% Callback for after the brush action has been completed
function ignoreGreen(~,eventdata)
% Extract plotted graphics objects
% Invert order because "Children" property is in reversed plotting order
hLines = flipud(eventdata.Axes.Children);
hLines(1).BrushData = hLines(1).BrushData .* 0;
end
Still, this is confusing for the user, becase as they're dragging the selection box, the green points will appear selected until the user lets go of the mouse button.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by