How to get brushed data point index or coordinate from a 3D Plot?

47 views (last 30 days)
Hello everyone.
I have a 3D plot made using plot3 and I would like to brush data from the plot and get back the index/coordinates of the brushed points. For that I'm trying to use the brush tool. I found a lot of question but not a clear answer for a 3D plot. This link (https://it.mathworks.com/matlabcentral/answers/385226-how-to-use-the-data-brush-tool-to-automatically-save-selected-points-in-multiple-line-plots) gives a solution but it seems that it doesn't work for a 3D plot. These are the data that I'm plotting and I would like to work on with the brush tool.
Pos=[-77.0871000000000,49.0849000000000,-1.78439000000000;-77.3056000000000,62.9298000000000,-1.79021000000000;-112.057000000000,49.1500000000000,-2.23801000000000;-130.987000000000,63.0496000000000,-2.49772000000000;-84.5025000000000,74.5152000000000,-1.79890000000000;-48.0342000000000,123.030000000000,-1.07363000000000;-46.1473000000000,148.599000000000,-0.788758000000000;-60.3364000000000,158.017000000000,-0.765587000000000;-55.5295000000000,150.991000000000,-0.835239000000000;-77.5969000000000,204.910000000000,-0.372025000000000;-55.9547000000000,174.323000000000,-0.553898000000000;-90.0147000000000,237.949000000000,0.124520000000000;-83.0690000000000,242.606000000000,0.299160000000000;-85.0367000000000,223.787000000000,-0.0354042000000000;-61.4736000000000,218.871000000000,0.0409176000000000;-61.7632000000000,232.992000000000,0.351617000000000;-83.9893000000000,172.176000000000,-0.864933000000000;-106.728000000000,249.891000000000,0.198643000000000;-95.4340000000000,271.076000000000,0.807391000000000;-77.1318000000000,296.928000000000,1.46174000000000;-71.5515000000000,254.276000000000,0.572107000000000;-65.1295000000000,284.953000000000,1.30063000000000;-53.3720000000000,284.821000000000,1.36086000000000;-49.1129000000000,183.624000000000,-0.367095000000000;-70.5364000000000,202.525000000000,-0.265945000000000;-139.879000000000,257.292000000000,0.0624518000000000;-158.696000000000,252.774000000000,-0.0256410000000000;-102.401000000000,155.937000000000,-1.29030000000000;-113.701000000000,135.004000000000,-1.62848000000000;-114.581000000000,177.072000000000,-1.06902000000000;-125.704000000000,149.061000000000,-1.63928000000000;-116.234000000000,144.345000000000,-1.55709000000000;-110.720000000000,102.421000000000,-1.88425000000000;-92.2718000000000,116.283000000000,-1.57063000000000;-141.306000000000,109.511000000000,-2.20037000000000;-171.676000000000,104.954000000000,-2.73569000000000;-168.926000000000,86.3366000000000,-2.86015000000000;-138.428000000000,83.9366000000000,-2.41759000000000;-121.910000000000,76.9308000000000,-2.25826000000000;-114.873000000000,191.128000000000,-0.888279000000000;-43.2178000000000,113.726000000000,-1.10431000000000;-133.061000000000,163.138000000000,-1.48366000000000;-43.2577000000000,116.047000000000,-1.08007000000000;-146.548000000000,135.171000000000,-1.97689000000000;-65.5535000000000,55.9816000000000,-1.65558000000000;-69.9526000000000,39.8507000000000,-1.73391000000000;-48.8588000000000,28.3079000000000,-1.51243000000000;-25.2249000000000,-6.12415000000000,-1.14503000000000;-13.3423000000000,-29.0091000000000,-1.16509000000000;16.6515000000000,-31.2525000000000,-0.780233000000000;32.6219000000000,-17.5402000000000,-0.679093000000000;25.6429000000000,-10.6962000000000,-0.761514000000000;9.53395000000000,-12.9853000000000,-0.897955000000000;2.58906000000000,-10.7015000000000,-0.985858000000000;-34.2558000000000,-22.1714000000000,-1.30195000000000;-55.0407000000000,-26.7655000000000,-1.52155000000000;-24.7224000000000,-45.0144000000000,-1.11548000000000;-3.64032000000000,-72.3385000000000,-0.791610000000000;14.9751000000000,-92.7517000000000,-0.455504000000000;12.6751000000000,-92.7607000000000,-0.471513000000000;2.13137000000000,25.9536000000000,-0.956257000000000;-76.0188000000000,-19.9127000000000,-1.78773000000000;24.8199000000000,60.3643000000000,-0.761241000000000;16.0655000000000,21.3439000000000,-0.937785000000000;22.6189000000000,51.1753000000000,-0.777079000000000;-9.23410000000000,19.0381000000000,-1.63527000000000;-0.874601000000000,-117.812000000000,-0.441541000000000;8.53739000000000,-142.724000000000,-0.0419276000000000;-19.0474000000000,-142.889000000000,-0.353302000000000;-33.0286000000000,-127.065000000000,-0.671494000000000;-31.5684000000000,-51.8812000000000,-1.18054000000000;-11.7447000000000,-188.179000000000,0.333837000000000;-27.8277000000000,-188.298000000000,0.119554000000000;-25.2536000000000,-219.974000000000,0.644616000000000;-11.5588000000000,-210.815000000000,0.694263000000000;-7.75112000000000,-120.118000000000,-0.509151000000000;-24.0674000000000,-102.007000000000,-0.807470000000000;-31.2431000000000,-79.2633000000000,-1.04147000000000;-2.22285000000000,-228.817000000000,1.00866000000000;-31.4394000000000,-63.2991000000000,-1.08576000000000;-37.7265000000000,-120.266000000000,-0.725351000000000;-58.4477000000000,-124.920000000000,-0.957239000000000;-72.2365000000000,-131.820000000000,-1.06026000000000;-93.0199000000000,-134.211000000000,-1.35777000000000;-88.1806000000000,-152.397000000000,-1.06029000000000;-104.821000000000,-116.040000000000,-1.75762000000000;-87.9686000000000,-170.576000000000,-0.840068000000000;-109.716000000000,-97.8078000000000,-1.93607000000000;-100.700000000000,-79.4920000000000,-1.88716000000000;-79.4992000000000,-104.521000000000,-1.44293000000000;-102.171000000000,-143.368000000000,-1.37396000000000;-68.2192000000000,-81.6687000000000,-1.42696000000000;-67.9650000000000,-102.194000000000,-1.26880000000000;-90.0249000000000,-193.308000000000,-0.553506000000000;-103.596000000000,-218.367000000000,-0.390971000000000;-131.451000000000,-207.236000000000,-1.03343000000000;-144.876000000000,-245.942000000000,-0.468829000000000;-128.394000000000,-270.698000000000,0.187753000000000;-125.814000000000,-295.572000000000,0.791392000000000;-110.125000000000,-252.419000000000,0.0360436000000000;-147.226000000000,-243.697000000000,-0.509872000000000;-134.673000000000,-327.291000000000,1.41655000000000;-136.276000000000,-193.647000000000,-1.21942000000000;-91.7713000000000,-245.470000000000,0.261741000000000;-96.4484000000000,-238.712000000000,0.0494684000000000;-115.070000000000,-225.267000000000,-0.429709000000000;-104.712000000000,-329.220000000000,1.80676000000000;-104.934000000000,-308.921000000000,1.37035000000000;-107.994000000000,-238.816000000000,-0.0741614000000000;-120.414000000000,-365.461000000000,2.50992000000000;-127.103000000000,-381.264000000000,2.75932000000000;-99.2536000000000,-407.887000000000,3.81607000000000;-81.0957000000000,-391.965000000000,3.65517000000000;-55.7333000000000,-407.344000000000,4.27217000000000;-35.2473000000000,-398.127000000000,4.32985000000000;-83.4926000000000,-380.760000000000,3.28985000000000;-98.8798000000000,-439.224000000000,4.63336000000000;-80.6247000000000,-434.531000000000,4.72254000000000;-97.3596000000000,-371.931000000000,2.92521000000000;-71.7363000000000,-409.801000000000,4.17687000000000;-81.3323000000000,-367.241000000000,2.96096000000000;-88.2580000000000,-362.820000000000,2.74991000000000;-70.0432000000000,-349.110000000000,2.68567000000000;-95.1025000000000,-367.405000000000,2.80011000000000;-102.050000000000,-362.993000000000,2.64732000000000;-68.2121000000000,-299.500000000000,1.59505000000000;-88.9832000000000,-292.942000000000,1.22582000000000;-96.0827000000000,-274.935000000000,0.794760000000000;-134.611000000000,-331.794000000000,1.49304000000000;-84.6585000000000,-265.771000000000,0.770256000000000;-49.1453000000000,-378.098000000000,3.63245000000000;-60.1501000000000,-423.074000000000,4.62050000000000;-102.733000000000,-299.865000000000,1.22527000000000;-125.416000000000,-136.665000000000,-1.85024000000000;-146.161000000000,-148.181000000000,-1.95252000000000;-146.840000000000,-100.241000000000,-2.50057000000000;-45,-326.289000000000,2.38448000000000;-31.3713000000000,-312.624000000000,2.30371000000000;-80.8526000000000,-414.393000000000,4.21433000000000;-38.0135000000000,-341.973000000000,2.92868000000000;-150.895000000000,-141.367000000000,-2.12070000000000;-62.2301000000000,-202.168000000000,-0.115153000000000;-48.4887000000000,-195.259000000000,0.0247025000000000;-60.0895000000000,-432.051000000000,4.99706000000000;-32.7349000000000,35.1929000000000,-1.23551000000000;-64.7442000000000,0.763141000000000,-1.52842000000000;-130.384000000000,-113.881000000000,-2.10000000000000;-41.7704000000000,-174.800000000000,-0.205899000000000;-60.1621000000000,-179.466000000000,-0.375382000000000;-60.3104000000000,-165.853000000000,-0.524450000000000;0.173930000000000,-1.55167000000000,-1.03810000000000;-27.6574000000000,3.04335000000000,-1.19323000000000;-32.6499000000000,-165.662000000000,-0.198262000000000;-112.626000000000,-56.6516000000000,-2.25302000000000;-108.083000000000,-49.7671000000000,-2.21134000000000;-131.628000000000,-31.4620000000000,-2.65938000000000;-113.103000000000,-26.8409000000000,-2.29617000000000;-104.151000000000,-1.58547000000000,-2.39636000000000;-147.814000000000,-38.3824000000000,-2.91561000000000;-45.7184000000000,-245.041000000000,0.817581000000000;-43.3309000000000,-254.052000000000,0.964777000000000;-26.3905000000000,78.9511000000000,-1.15031000000000;-30.9347000000000,72.0425000000000,-1.20862000000000;-93.3995000000000,-311.051000000000,1.54657000000000;-54.1664000000000,-95.2983000000000,-1.17039000000000;-159.736000000000,-24.6132000000000,-3.04698000000000;-161.784000000000,-40.7031000000000,-3.04799000000000;-150.618000000000,-13.0873000000000,-2.88502000000000;-163.539000000000,-75.1212000000000,-2.89401000000000;-147.333000000000,-68.2047000000000,-2.74560000000000;-157.976000000000,9.92956000000000,-3.23492000000000;-84.5408000000000,-72.5889000000000,-1.77248000000000;-133.065000000000,-88.7581000000000,-2.37006000000000;-49.2189000000000,-369.107000000000,3.37770000000000;-136.925000000000,-331.824000000000,1.50501000000000;-56.8172000000000,-67.9313000000000,-1.37133000000000;3.06248000000000,127.412000000000,-0.525562000000000;8.20649000000000,92.6754000000000,-0.780889000000000;-76.6686000000000,23.7269000000000,-1.87450000000000;-126.364000000000,283.259000000000,0.914363000000000;-44.4802000000000,185.928000000000,-0.296150000000000;-27.9660000000000,176.454000000000,-0.298776000000000;-30.0587000000000,162.474000000000,-0.492677000000000;-76.2565000000000,254.324000000000,0.561314000000000;-16.3208000000000,21.3874000000000,-1.10368000000000;-75.7046000000000,-238.523000000000,0.341667000000000;-41.5446000000000,-199.737000000000,0.202560000000000;-177.074000000000,26.1246000000000,-3.21160000000000;-158.531000000000,35.3420000000000,-2.94055000000000;-73.6165000000000,118.518000000000,-1.37234000000000;-144.728000000000,262.088000000000,0.194012000000000;-40.6463000000000,-65.6079000000000,-1.22550000000000;-28.7076000000000,218.593000000000,0.332909000000000;-147.137000000000,51.5097000000000,-2.76341000000000;-80.0299000000000,323.099000000000,2.06387000000000;-71.2342000000000,237.784000000000,0.325388000000000;-54.3839000000000,337.055000000000,2.52036000000000;-101.663000000000,340.079000000000,2.50689000000000;-130.328000000000,-118.446000000000,-2.02645000000000;-94.1937000000000,323.270000000000,2.01918000000000;-136.082000000000,295.227000000000,1.11711000000000;-148.260000000000,309.650000000000,1.47044000000000;-85.0164000000000,102.324000000000,-1.54969000000000;-41.7898000000000,-431.806000000000,5.10473000000000;-149.064000000000,-107.111000000000,-2.46831000000000;-34.7497000000000,294.058000000000,1.61871000000000;-81.6314000000000,42.1723000000000,-1.85512000000000;-158.423000000000,240.960000000000,-0.237178000000000;-137.458000000000,149.136000000000,-1.70301000000000;-20.2468000000000,-33.5814000000000,-1.07161000000000;-47.5559000000000,-67.9073000000000,-1.29058000000000;-105.334000000000,292.522000000000,1.25911000000000;-14.4013000000000,202.056000000000,0.149049000000000;-125.930000000000,42.2306000000000,-2.48895000000000;-144.776000000000,-84.2245000000000,-2.52355000000000;-61.2109000000000,74.4525000000000,-1.47712000000000;-119.554000000000,295.058000000000,1.24977000000000;-158.613000000000,149.258000000000,-1.91007000000000;-81.3840000000000,387.629000000000,3.86708000000000;-13.3281000000000,-276.344000000000,1.79797000000000;-61.7162000000000,-47.3711000000000,-1.52933000000000;-167.296000000000,217.424000000000,-0.785833000000000;-19.7134000000000,239.627000000000,0.682653000000000;-85.8092000000000,16.8153000000000,-2.23284000000000;-156.860000000000,175.016000000000,-1.47327000000000;-44.5695000000000,315.543000000000,2.12693000000000;-120.155000000000,321.238000000000,1.93414000000000;-78.5321000000000,363.654000000000,3.22446000000000;-124.869000000000,217.076000000000,-0.442137000000000;-47.1323000000000,327.434000000000,2.31038000000000;-116.202000000000,19.1509000000000,-2.33862000000000;-63.4600000000000,-315.234000000000,1.93847000000000;-83.9254000000000,394.882000000000,4.18568000000000;-6.95164000000000,173.970000000000,-0.143792000000000;-150.107000000000,288.252000000000,0.891929000000000;-130.703000000000,369.128000000000,3.17493000000000;-145.258000000000,381.353000000000,3.66081000000000;-111.005000000000,-163.894000000000,-1.94818000000000;-54.8600000000000,360.925000000000,3.17764000000000;-114.546000000000,388.103000000000,3.81146000000000;-119.699000000000,407.353000000000,4.33484000000000;-81.9691000000000,416.421000000000,4.70847000000000;-74.4969000000000,397.134000000000,4.22983000000000;-79.4171000000000,406.795000000000,4.47086000000000;-164.557000000000,9.80410000000000,-4.85330000000000;-88.6964000000000,397.331000000000,4.18691000000000;-129.660000000000,426.791000000000,5.07974000000000;-161.936000000000,288.377000000000,0.832355000000000;-96.8900000000000,450.338000000000,5.77511000000000;-148.511000000000,419.827000000000,4.81755000000000;-127.496000000000,436.392000000000,5.39572000000000;-111.124000000000,448.194000000000,5.82040000000000;-122.881000000000,443.518000000000,5.56573000000000;-126.817000000000,-4.06003000000000,-4.98641000000000;-94.8721000000000,12.1154000000000,-3.06717000000000;61.8351000000000,7.80607000000000,2.35060000000000;91.7239000000000,7.78150000000000,2.45252000000000;119.184000000000,14.6115000000000,2.54889000000000;148.965000000000,10.0097000000000,2.50284000000000;176.328000000000,12.2618000000000,2.56889000000000;205.891000000000,19.0656000000000,2.60988000000000;233.155000000000,19.0309000000000,2.62570000000000;262.631000000000,21.2475000000000,2.45524000000000;289.783000000000,21.2259000000000,2.57591000000000;-183.928000000000,-3.79251000000000,-1.90306000000000;-212.434000000000,-6.02586000000000,-0.868612000000000;-49.9798000000000,7.25925000000000,-5.71650000000000;-242.044000000000,-6.17329000000000,-4.01714000000000;357.256000000000,-71.4926000000000,-0.224039000000000;343.815000000000,-62.5309000000000,-0.260049000000000;368.464000000000,-62.5010000000000,-0.332574000000000;393.010000000000,-89.3767000000000,-0.409973000000000;375.211000000000,-46.7561000000000,-0.360284000000000;384.170000000000,-44.5042000000000,-0.442244000000000;364.103000000000,5.06046000000000,-0.481427000000000;355.088000000000,-15.2397000000000,-0.345203000000000;357.325000000000,-19.7462000000000,-0.364386000000000;332.619000000000,-22.0086000000000,-0.277509000000000;388.719000000000,-17.5013000000000,-0.485288000000000;348.280000000000,-91.7227000000000,-0.104784000000000;406.638000000000,-15.2498000000000,-0.547540000000000;379.562000000000,-116.278000000000,-0.247098000000000;395.188000000000,-113.995000000000,-0.371086000000000;383.966000000000,-156.489000000000,-0.171905000000000;386.242000000000,-127.443000000000,-0.233034000000000;357.280000000000,-51.2683000000000,-0.271743000000000;411.027000000000,-39.9841000000000,-0.478704000000000;395.157000000000,-131.880000000000,-0.223615000000000;392.826000000000,-189.884000000000,-0.154733000000000;408.396000000000,-192.023000000000,-0.105614000000000;408.454000000000,-163.071000000000,-0.253022000000000;404.140000000000,-105.023000000000,-0.264303000000000;410.960000000000,-60.1905000000000,-0.448446000000000;399.905000000000,-21.9927000000000,-0.447130000000000;412.820000000000,-200.897000000000,-0.101748000000000;412.931000000000,-151.900000000000,-0.299816000000000;344.078000000000,114.066000000000,-0.447662000000000;362.155000000000,120.836000000000,-0.428023000000000;346.244000000000,70.7924000000000,-0.397772000000000;355.236000000000,61.6815000000000,-0.424510000000000;382.272000000000,72.9497000000000,-0.546876000000000;391.298000000000,82.0014000000000,-0.631873000000000;364.345000000000,100.284000000000,-0.605376000000000;373.421000000000,118.480000000000,-0.580168000000000;395.765000000000,75.1643000000000,-0.665994000000000;335.003000000000,91.2993000000000,-0.411979000000000;355.433000000000,139.129000000000,-0.478059000000000;355.483000000000,157.431000000000,-0.522473000000000;405.056000000000,141.135000000000,-0.701240000000000;375.834000000000,161.889000000000,-0.550018000000000;389.429000000000,175.520000000000,-0.734806000000000;389.562000000000,205.376000000000,-0.625878000000000;375.965000000000,196.312000000000,-0.484156000000000;357.875000000000,201.023000000000,-0.506064000000000;400.718000000000,175.482000000000,-0.602199000000000;376.076000000000,226.201000000000,-0.520198000000000;371.385000000000,180.273000000000,-0.470855000000000;369.124000000000,180.290000000000,-0.451387000000000;436.070000000000,21.0175000000000,2.01442000000000];
plot3(Pos(:,1),Pos(:,2),Pos(:,3), 'o');
axis equal;
view(0,90)
brush on
h = brush;
Any help is really appreciated. Thank you in advance for the reply.

Accepted Answer

Divya Gaddipati
Divya Gaddipati on 5 Mar 2020
Hi,
The following snippet might be of help to you.
Handle = plot3(Pos(:,1),Pos(:,2),Pos(:,3), 'o');
axis equal;
view(0,90)
brush on
Select the required data and run the following to get the brushed points:
xd = get(Handle, 'XData');
yd = get(Handle, 'YData');
zd = get(Handle, 'ZData');
brush = get(Handle, 'BrushData');
brushed_x = xd(logical(brush));
brushed_y = yd(logical(brush));
brushed_z = zd(logical(brush));
figure, plot3(brushed_x, brushed_y, brushed_z, 'o');
Hope this helps!
  2 Comments
MJ
MJ on 29 Jul 2021
How do you get the indices? for some reason the size of Pos and size of brush are different

Sign in to comment.

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!