필터 지우기
필터 지우기

How to plot scatter 3D with different marker?

조회 수: 8 (최근 30일)
Putri Basenda Tarigan
Putri Basenda Tarigan 2020년 12월 5일
댓글: Putri Basenda Tarigan 2020년 12월 6일
Hello everyone.
If I have
X=randi(9,3,1)
Y=randi(9,3,1)
Z=randi(9,3,1)
How can I plot scatter 3D X,Y,Z with different marker?
For example I want
X(1),Y(1),Z(1) with marker 'x'
X(2),Y(2),Z(2) with marker '*'
X(3),Y(3),Z(3) with marker '^'
Thanks in advance

채택된 답변

Walter Roberson
Walter Roberson 2020년 12월 6일
편집: Walter Roberson 2020년 12월 6일
markers = {'x', '*', '^', '.', 'o', 's', 'd', '+', 'v', '>', '<', 'p', 'h', '_', '|'};
nmarkers = length(markers);
for K = 1 : length(X)
markidx = mod(K-1, nmarkers) + 1;
line(X(K), Y(K), Z(K), 'Marker', markers{markidx});
end
This cycles through the markers if need be.
Note: The '_' and '|' markers are new as of R2020b.
  댓글 수: 3
Walter Roberson
Walter Roberson 2020년 12월 6일
X=randi(9,3,1);
Y=randi(9,3,1);
Z=randi(9,3,1);
markers = {'x', '*', '^', '.', 'o', 's', 'd', '+', 'v', '>', '<', 'p', 'h', '_', '|'};
nmarkers = length(markers);
for K = 1 : length(X)
markidx = mod(K-1, nmarkers) + 1;
line(X(K), Y(K), Z(K), 'Marker', markers{markidx});
end
xlim([0 10]); ylim([0 10]); zlim([0 10]);
xlabel('x'); ylabel('y'); zlabel('z');
view(3)
Putri Basenda Tarigan
Putri Basenda Tarigan 2020년 12월 6일
Thankyou so much Sir

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

추가 답변 (0개)

카테고리

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