Different color for every point - Scatter3

4 ビュー (過去 30 日間)
Diego Hens
Diego Hens 2020 年 11 月 19 日
編集済み: KALYAN ACHARJYA 2020 年 11 月 19 日
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?

回答 (1 件)

KALYAN ACHARJYA
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

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by