How do I set tooltip strings on scatter children?
Show older comments
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
Accepted Answer
More Answers (2)
Walter Roberson
on 8 Jun 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
on 8 Jun 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....
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!