How to connect points in the scatter3 plot?

조회 수: 17 (최근 30일)
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim 2022년 3월 27일
댓글: Star Strider 2022년 3월 27일
I have 2 vectors both have x,y and z coordinates (see attached files). I want to creat scatter plot such that point 1 in V_1 is connected to only point 1 of V_2 and similary point 2 of V_1 is only connected to the point 2 of V_2 and so on. How can I do that ?

채택된 답변

Star Strider
Star Strider 2022년 3월 27일
To connect only the corresponding points (without connecting any others) requires a loop —
LD1 = load('V_1.mat');
V_1 = LD1.V_1;
LD2 = load('V_2.mat');
V_2 = LD2.V_2;
figure
hold on
for k = 1:size(V_1,1)
plot3([V_1(k,1) V_2(k,1)], [V_1(k,2) V_2(k,2)], [V_1(k,3) V_2(k,3)], '.-')
end
hold off
grid on
view(60,15)
xlabel('X')
ylabel('Y')
zlabel('Z')
A scatter plot will not connect the points, so plot3 is required to draw the connecting lines. Choose whatever marker works best. I chose a small ‘dot’ marker here because the points are densely concentrated in part of the plot.
.
  댓글 수: 2
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim 2022년 3월 27일
Thanks that is exactly what I want.
Star Strider
Star Strider 2022년 3월 27일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by