Hi everyone smarter than me, (Upfront--> Can I get some Matlab Engineer/Guru eyes on this ?)
I'm looking to extract exactly WHICH data points have been brushed by the user in a scatter plot.
Clearly this is tracked somewhere, because if you right click the plot you can
  1. Export the brushed data to a variable
  2. Delete brushed/unbrushed points
  3. Copy to the command line
How can I get that list of brushed data programmatically?
My ultimate goal is to brush a linked set of scatter plots, but but a first step is to just select a collection of points, and get a logical selection out again.
I'd like to hook into the pre-built work Matlab engineers have done, rather than home brew a janky and slow version.
Does anyone know where Matlab keeps this secret sauce?
------------------------------
Here's what I've tried so far
My best guess starting point is using the struct() function to display hidden internal properties of the brush object.
However, despite the new field "ModeHandle", I can't find what I'm after once I've done that.
-------------------------
Example of my flow:
% make a scatter plot
x = 0.1:0.1:100;
y = sin(x)./x;
scatter(x,y);
b = brush; % make the brush object
b.Enable = 'on' % enable brushing
Off I go to brush (see photo above)
Now expose the hidden brush object
b2 = struct(b); % Make brush object show all hidden properties
ModeHandle field appears, but I can't seem to find where the brushed points/ properies are.
I've delved deep into ModeHandle, with no luck.
Any help navigating the ModeHandle field would be appreciated.

댓글 수: 2

Allen
Allen 2023년 5월 18일
It looks like this topic has already been covered. See @Yair Altman's answer to the linked post.
I am also including the link he proivded to his Undocumented Matlab webpage.
Scott Smith
Scott Smith 2023년 5월 18일
Awesome! Thanks so much! This and the accepted answer have been a big help!

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

 채택된 답변

Adam Danz
Adam Danz 2023년 5월 18일

1 개 추천

To get the coordinates of selected data points, you can follow the example in this answer.
That answer shows that BrushData is a property of the object that has been brushed and contains a logical index of the data points that were selected. You can use this logical index to extract the coordinates from the XData, YData, ZData properties (for most graphics objects).

댓글 수: 1

Scott Smith
Scott Smith 2023년 5월 18일
So helpful. I wish that this was easier to find out/ that "BrushedData" wasn't a hidden property.
Thanks!

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

추가 답변 (1개)

Scott Smith
Scott Smith 2023년 5월 18일

0 개 추천

Also as the original poster,
This does in fact work for scatter plots and (I imagine) linked scatter plots where simultaneous brushing is being exceuted properly.
quick example code
x = 0:0.1:100;
y = sin(x)./x;
s = scatter(x,y);
brush on
Then just brush desired data
Finally to get a logical/index of the brushed data
BData = get(s,'BrushData');

카테고리

도움말 센터File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

2023년 5월 17일

답변:

2023년 5월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by