- Extract the displayed text strings
- Convert them back to numbers
- Those numbers are the indices
TextScatter implementation does not expose the indices it chose for display when 'TextDensityPercentage' is used
28 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
rng(10) % for reproducibility
n=100;
x = randn(n,1);
y = randn(n,1);
seq = (1:n)';
h=textscatter(x,y,string(seq), ...
'TextDensityPercentage',20, ...
'DisplayName','text')
I want to know the indexes of the unis which have been displayed by function textscatter from handle h (in this case 1, 4 and 22) or from findall, ancestor, ....
I wanted to use textscatter with geoaxes but it seems it is not supported. Therefore the idea is to project the map on cartesian axes and then retrieve the indexes of displayed units from textscatter with 'Name', Value 'TextDensityPercentage',20, but I need to know the indexes.
Any other idea is welcome (apart from "implementing my own label-selection rule" which labels points if they are not closer than a threshold) .
Copilot and ChatGPT claim it is not possible but I want to have your opinion.
Thank you in advance
0 Kommentare
Antworten (1)
Yashwanth
am 16 Jan. 2026 um 6:34
Hi Marco,
You can give a try on recovering the indices via label text, since your labels are the indices themselves, you can
Please refer to the code section for implementation.
txtHandles = findall(h, 'Type', 'Text');
displayedLabels = string({txtHandles.String});
displayedIdx = str2double(displayedLabels);
displayedIdx = sort(displayedIdx);
2 Kommentare
Siehe auch
Kategorien
Mehr zu Phased Array Design and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

