How to plot scatter 3D with different marker?

7 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 6 Dec 2020
Edited: Walter Roberson on 6 Dec 2020
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 Comments
Walter Roberson
Walter Roberson on 6 Dec 2020
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)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!