How do I set tooltip strings on scatter children?
Afficher commentaires plus anciens
Hello,
I am attempting to programmatically set the TooltipString property for all of the points in my scatter plot and so far have not quite gotten there.
My intention is something like:
h = scatter(xPts,yPts,'b+');
allPts = get(h,'Children');
for i=1:length(allPts)
set(allPts{i},'TooltipString',pointNames(i));
end
... where the first get() would return the list of handles to point objects that could have individual tooltips set to their point names. I am apparently not getting the object hierarchy correct and/or am on the wrong track entirely.
Is an example of this reasonably documented?
Thanks, david
1 commentaire
David O
le 8 Juin 2011
Réponse acceptée
Plus de réponses (2)
Walter Roberson
le 8 Juin 2011
0 votes
scatter() does not create individual point objects.
I do not know if it is possible to set tooltipstring strings for the individual points. The only approach I can think of at the moment is to create a datacursor object and set the callback function for it to figure out which point is involved and display the appropriate string.
Matt Fig
le 8 Juin 2011
0 votes
The children of the handle to h are patch objects, which have no tooltipstring. You could do something similar to what I did here, though it would take a more work because patches don't have a position property. So you would have to translate the xdata and ydata into positions relative to the figure....
Catégories
En savoir plus sur App Building dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!