Different color for every point - Scatter3
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm using the function Scatter3 to plot a variable number of points (I use the function getpts to click on an existing plot and get the points), for example a 2x4 matrix (x and y coordinates). As I said, it's variable depending on how many times I click, so it could also be a 2x1 or 2x5 (etc) matrix. Then I use this points to draw them on another scatter3 figure.
It would be tremendously helpful if I could have every point have a different color, it doesn't matter which. It would help me determine where each point is plotted on the other figure.
Can you help me figure this out?
0 个评论
回答(1 个)
KALYAN ACHARJYA
2020-11-19
编辑:KALYAN ACHARJYA
2020-11-19
"It would be tremendously helpful if I could have every point have a different color, it doesn't matter which. It would help me determine where each point is plotted on the other figure."
One Way: Sample data example is taken from MATLAB docs
[X,Y,Z] = sphere(16);
x = [0.5*X(:); 0.75*X(:); X(:)];
y = [0.5*Y(:); 0.75*Y(:); Y(:)];
z = [0.5*Z(:); 0.75*Z(:); Z(:)];
figure,scatter3(x,y,z);
% Now plot the same with different colors
figure;
for i=1:length(x)
plot3(x(i),y(i),z(i),'o');
hold on
grid on;
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!