How to modify scatter3 default 'mouseover' display

Is it possible to change the way the values are displayed in scatter3 when I mouse over a given data points?
I have created this plot, representating a number of CIE Lab data points (see below). The problem is that, ideally, the Labels ought to read Lab (and not XYZ) and the order needs to change from bottom to top. Such that, in the screen capture, I would like to have scatter3 show
L 87.8179
a -79.2574
b 80.987

2 commentaires

According to the values in the datatip and the axis labels, the datatip should be
b 87.8179 % not L
a -79.2574
L 80.987 % not b
You are right (and I was wrong) :
L = 80.987
a = -79.2574
b = 87.8179
In other words, X = L and Z = b

Connectez-vous pour commenter.

Réponses (1)

Adam Danz
Adam Danz le 16 Déc 2021
Modifié(e) : Adam Danz le 16 Déc 2021
Note that this demo assigns axis labels according your desciption of the desired datatip labels (L,a,b) whereas in your image, the axes appear to be x=b, y=a, z=L, unless the camera view angle or the camera up vector has been changed from default.
% Create scatter, return handle
h = scatter3(rand(1,10),rand(1,10),rand(1,10));
xlabel('L')
ylabel('a')
zlabel('b')
% Redefine labels
h.DataTipTemplate.DataTipRows(1).Label = 'L';
h.DataTipTemplate.DataTipRows(2).Label = 'a';
h.DataTipTemplate.DataTipRows(3).Label = 'b';
% Show datatip
datatip(h, h.XData(1),h.YData(1),h.ZData(1));
Alternatively to avoid mislableing the x|y|z values, you could just use the xlabel, ylabel, zlabel strings,
ax = ancestor(h, 'axes'); % get axis handle
h.DataTipTemplate.DataTipRows(1).Label = ax.XLabel.String;
h.DataTipTemplate.DataTipRows(2).Label = ax.YLabel.String;
h.DataTipTemplate.DataTipRows(3).Label = ax.ZLabel.String;

8 commentaires

Roger Breton
Roger Breton le 16 Déc 2021
Modifié(e) : Adam Danz le 28 Déc 2021
I have no idea idea how to change the camera view angle or vector are accessed. So those are by defaults.
This is how I have the whole thing setup :
scatter3(Lab(3,:),Lab(2,:),Lab(1,:),markersize,RGB,'fill');
xlabel('b*'),ylabel('a*'),zlabel('L*');
title('CIE-L*a*b* coordinates');
axis([min_Lab(3) max_Lab(3) min_Lab(2) max_Lab(2) min_Lab(1) max_Lab(1)]);grid on;hold on;
% draw black lines indicating axis
line([min_Lab(3) max_Lab(3)],[0 0],[0 0],'color',[0 0 0],'lineWidth',linewidth); % Axis L* == a* == 0
line([0 0],[min_Lab(2) max_Lab(2)],[0 0],'color',[0 0 0],'lineWidth',linewidth); % Axis L* == b* == 0
line([0 0],[0 0],[min_Lab(1) max_Lab(1)],'color',[0 0 0],'lineWidth',linewidth); % Axis a* == b* == 0
Notice that I'm using code from here :
Wow! I incorporated your code into my existing code and it works!
Here's the results -- wow! THANK YOU SO VERY MUCH!!!!
> xlabel('b*'),ylabel('a*'),zlabel('L*');
so then you would define,
h.DataTipTemplate.DataTipRows(1).Label = 'b';
h.DataTipTemplate.DataTipRows(2).Label = 'a';
h.DataTipTemplate.DataTipRows(3).Label = 'L';
@Roger Breton your image above mislabels the x,y,z values. I've updated my answer (see bottom) to show how you can use the axis labels to avoid this kind of mistake.
Wow! Thank you so much. I'll stick with your first answer for now, though... ;-)
There's still so much that's commanding my attention in this humble project...
As long as the x|y|z tooltip labels correspond to your x|y|z axis labels, you're good to go. Click on a few points to verify that. In the point in your image above, the values for L and b are close to each other (80,87) so it's hard to confirm.
It's very simple, the data tip labels are in order of X Y Z, or in your plot, b a L.
This is what I've been trying to tell you in almost all of my comments above.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Labels and Annotations dans Centre d'aide et File Exchange

Produits

Version

R2021b

Modifié(e) :

le 28 Déc 2021

Community Treasure Hunt

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

Start Hunting!

Translated by