Label each data points?

조회 수: 4 (최근 30일)
steamrice
steamrice 2020년 3월 12일
댓글: Walter Roberson 2020년 4월 29일
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