How do I plot one 3D vector arrow for all points in a 3d scatter

조회 수: 10 (최근 30일)
AV
AV 2019년 12월 6일
답변: AV 2019년 12월 9일
How do I plot one 3D vector arrow for all points in a 3d scatter?
I have the following code and wish to create one 3d vector arrow representing the overall direction of variables A, B and C combined.
Your help would be most welcome!
% creating 3d scatter plot
% Load data
T = table((rand(100,3)));
T = [table(T.Var1(:,1),'VariableNames',{'A'}),table(T.Var1(:,2),'VariableNames',{'B'}),table(T.Var1(:,3),'VariableNames',{'C'})];
% Make a color index
nc = 16;
offset = 1;
% Create a 3D scatter plot using the scatter3 function
figure
scatter3(T.A, T.B, T.C, 20, 'filled')
view(-34, 14)
% Add title and axis labels
title('Title')
xlabel('A')
ylabel('B')
zlabel('C')

답변 (2개)

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019년 12월 6일
편집: JESUS DAVID ARIZA ROYETH 2019년 12월 6일
% creating 3d scatter plot
% Load data
T = table((rand(100,3)));
T = [table(T.Var1(:,1),'VariableNames',{'A'}),table(T.Var1(:,2),'VariableNames',{'B'}),table(T.Var1(:,3),'VariableNames',{'C'})];
% Make a color index
nc = 16;
offset = 1;
% Create a 3D scatter plot using the scatter3 function
zer=zeros(size(T,1),1)
figure
plot3(T.A,T.B,T.C,'r-')
view(-34, 14)
% Add title and axis labels
title('Title')
xlabel('A')
ylabel('B')
zlabel('C')
  댓글 수: 2
AV
AV 2019년 12월 6일
Thank you very much. This seems to display multiple vectors for the multipe points. Is there a way to combine all into 1 overall 3d vector so there is just one line?
JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019년 12월 6일
I edited the answer, please test it again

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


AV
AV 2019년 12월 9일
Thanks for helping that unfortunately created one vector connecting multiple points. Ideally I would like to generate one 3D vector arrow for all points in a 3d scatter. I have attached a diagram of one vector arrow added artificially to show an example of the desired end result.
Your help would be much appreciated.
testarrow3dscattter.png

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by