add data information with scatter or plot

14 Ansichten (letzte 30 Tage)
ELISABETTA BILLOTTA
ELISABETTA BILLOTTA am 20 Aug. 2021
Kommentiert: Turlough Hughes am 21 Aug. 2021
I created circles like these with the plot and scatter function. but now I have to figure out how I can enter a different value for each point, each star. practically every point / star corresponds to a coordinate (x, y) but also to a value (z) that I have to insert and these z values are all different from each other. I would like to get to the point where by moving the mouse on a particular point / star, both the values of x and y can come out, but also that of z. how can I do?

Akzeptierte Antwort

Turlough Hughes
Turlough Hughes am 20 Aug. 2021
Bearbeitet: Turlough Hughes am 20 Aug. 2021
Personally, I would just use scatter3 and then look at the data from above (along the z-axis). So something like:
scatter3(x,y,z)
view(0,90)
axis equal
Modifying the datatip labels in a 2d scatter plot is also possible though:
hp = scatter(x,y);
hp.DataTipTemplate.DataTipRows(3) = dataTipTextRow('Z',z);
axis equal
The above code can be tested with the following data:
x = -1:0.1:1;
y = [sqrt(1-x.^2) -sqrt(1-x.^2)];
x = repmat(x,1,2);
z = rand(1,numel(x));
  3 Kommentare
ELISABETTA BILLOTTA
ELISABETTA BILLOTTA am 21 Aug. 2021
yes yes thanks :)
Turlough Hughes
Turlough Hughes am 21 Aug. 2021
Good stuff. Can you accept the answer in that case.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by