MATLAB: How to plot scatter 3D with different marker

3d plot3d scatter

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

Best Answer

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.