Label each data points?

4 次查看(过去 30 天)
Hello there,
I have a .xls file that contains x,y,z vertics. The sequence goes something like this (that header of each): x0,y0,z0,x1,y2,z2,..........x1000,y1000,z1000 (1000data points for each x,y,z). I am wondering is it possible to use scratter3 to plot the points with its label (x0,y0,z0,x1,y2,z2,..........x1000,y1000,z1000) so I can identity/access that particular point?
Many thanks!

采纳的回答

Walter Roberson
Walter Roberson 2020-3-12
scatter3 cannot do labels.
You can text() and pass it vectors of x y z and a cell array of character vectors that are corresponding labels or a string array. For example string(1:1000).'
  37 个评论
steamrice
steamrice 2020-3-14
I commented the for loop I had
Walter Roberson
Walter Roberson 2020-3-14
I would recommend starting by removing the
clc;clear all; close all

请先登录,再进行评论。

更多回答(1 个)

steamrice
steamrice 2020-3-15
Sorry for the late reply! I tried that and still got the same result..
  3 个评论
steamrice
steamrice 2020-4-26
Sorry for left you hanged. I was working on the other project. The below code from you suggested eailer work!
clc;clear all;
[num,txt,raw] = xlsread('test_april24.csv'); %change the excel file name when received the new one
for i = 2:3:3002-2
a = num(3,i);
b = num(3,i+1);
c = num(3,i+2);
k=scatter3(a,b,c, 'filled');
S=string(1:3662).';
text(a, b, c, S);
row = dataTipTextRow('Index: ',i');
k.DataTipTemplate.DataTipRows(end+1) = row;
hold on
end
The label also showing the the point. However, if I can ask one more question, from what I understand, the 3D plot I am seeing and each point is coming from each x,y,z (x1,y1,z1 forms a point). And the label is showing the total point 3002. Is there a way to group the index point? (x1,y1,z1 would label as index 1and x3000,y3000,z3000 would label as 1500)?
I have been trying to modifiy this line,
row = dataTipTextRow('Index: ',i');
to somthing like
index=1:1500
row = dataTipTextRow('Index: ',index');
But it would only shows index as all 1 (i think it did not work if I do that inside the for loop..)
Sorry my thought process is a bit messy..
Walter Roberson
Walter Roberson 2020-4-29
row = dataTipTextRow('Index: ',i/2);
perhaps?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by