Different color for every point - Scatter3

2 visualizaciones (últimos 30 días)
Diego Hens
Diego Hens el 19 de Nov. de 2020
Editada: KALYAN ACHARJYA el 19 de Nov. de 2020
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?

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 19 de Nov. de 2020
Editada: KALYAN ACHARJYA el 19 de Nov. de 2020
"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

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by