How can I extract the x and y coordinates when hovering over a "heatmap"?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 13 Avr 2020
Réponse apportée : MathWorks Support Team
le 27 Avr 2020
I am using a "heatmap" object and I would like to be able to select one cell and be able to get the position of it, through code, not only by reading it from the dataTips window. Is there a property or a callback which allows me to do that?
Réponse acceptée
MathWorks Support Team
le 13 Avr 2020
As of MATLAB R2019b, this is not possible. Other objects such as "imagesc" allow the exact functionality that you require. In fact, you can use their "ButtonDownFcn" method to extract the coordinates of the point where you click in the figure. Therefore, as a workaround, you could use the following script to create an image object which looks like a "heatmap" and extract the position of the mouse:
d = magic(5);
im = imagesc(d);
[x,y] = meshgrid(1:5);
labels = num2str(d(:));
text(x(:),y(:),labels);
im.ButtonDownFcn = @(s,e) disp(e)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!