# connecting points in scatter3 plot?

조회 수: 93(최근 30일)
Sanjoy Basak 2014년 11월 4일
답변: Sanjoy Basak 2014년 11월 4일
hi there. I am trying to connect points in a scatter3 plot. i tried using line, but that is applicable for 2D plot. but the data contains 3 dimensions. can anyone please tell me which command should i use after the line to connect points? thanks in advance.
scatter3(objlist.r_c(1,1,:),objlist.r_c(2,1,:),objlist.r_c(3,1,:))

댓글을 달려면 로그인하십시오.

### 채택된 답변

Matt Tearle 2014년 11월 4일
OK, now I understand the problem. The issue isn't that the data is representing 3-dimensional points, but that it's stored in a 3-D array. So you need to squeeze or reshape your data into vectors:
x = objlist.r_c(1,1,:);
x = x(:);
y = objlist.r_c(2,1,:);
y = y(:);
z = objlist.r_c(3,1,:);
z = z(:);
scatter3(x,y,z);
line(x,y,z)
% or plot3(x,y,z,'o-')
Or
x = squeeze(objlist.r_c(1,1,:));
y = squeeze(objlist.r_c(2,1,:));
z = squeeze(objlist.r_c(3,1,:));
scatter3(x,y,z);
line(x,y,z)

댓글을 달려면 로그인하십시오.

### 추가 답변(3개)

Matt Tearle 2014년 11월 4일
편집: Matt Tearle 2014년 11월 4일
plot3(rand(5,1),rand(5,1),rand(5,1),'o-')
But I also don't understand what the problem is with line. This does the same as plot3:
x = rand(5,1);
y = rand(5,1);
z = rand(5,1);
scatter3(x,y,z)
line(x,y,z)
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

Sanjoy Basak 2014년 11월 4일
my data has 3 dimensions as you can see here..
(objlist.r_c(1,1,:) there is a z dimension here.. line only deals with 2 dimension points..line is not working..can you tell me any other way or any other command to join the points? no just a straight line, something else like spline would also be fine..
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

Sanjoy Basak 2014년 11월 4일
thank you very much...now it is working fine..:)

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!
{"ft_lang_label":"__label__en","ft_lang_prob":0.83795613,"math_prob":0.9824889,"size":1291,"snap":"2022-05-2022-21","text_gpt3_token_len":468,"char_repetition_ratio":0.14996114,"word_repetition_ratio":0.0,"special_character_ratio":0.35476375,"punctuation_ratio":0.2747253,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99016994,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-26T18:02:16Z\",\"WARC-Record-ID\":\"<urn:uuid:0db93c11-4e7f-4145-b5ef-014bca00dc31>\",\"Content-Length\":\"149178\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fa3631f9-965f-4285-9078-01635f454ea8>\",\"WARC-Concurrent-To\":\"<urn:uuid:6f93aa43-3aaf-40c1-8106-204464a6d972>\",\"WARC-IP-Address\":\"23.194.181.89\",\"WARC-Target-URI\":\"https://kr.mathworks.com/matlabcentral/answers/161287-connecting-points-in-scatter3-plot\",\"WARC-Payload-Digest\":\"sha1:2P4WXTHN3XS77BSAECTNJIZWIVWQKQTL\",\"WARC-Block-Digest\":\"sha1:3RCYKFSXH24VFEPXPREU3NX3VZLZELXW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662619221.81_warc_CC-MAIN-20220526162749-20220526192749-00724.warc.gz\"}"}