Different color for every point - Scatter3

조회 수: 2 (최근 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 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