Defining scatter plot with different 'markers' & 'colors'

3 visualizaciones (últimos 30 días)
kenneth lee
kenneth lee el 23 de Feb. de 2020
Comentada: Rik el 13 de Mzo. de 2020
Hi i am plotting a 3D scatter plot however i have to mark all 12 different classes on the 4th colomun in the attached file with 12 different markers and colors. Is there a way to randomize the 12 colors and markers all do i have to define them one by one? l only know how to do up till the 3d plot. Thanks in advance! :)
function plot3Ddata(x,y,z)
test = xlsread('HQ3.xlsx', 'A2:C223');
x=test(:,1);
y=test(:,2);
z=test(:,3);
scatter3(x,y,z);
end
the above code is my code for now...

Respuesta aceptada

Rik
Rik el 23 de Feb. de 2020
This should be close to what you need:
test = xlsread('HQ3.xlsx', 'A2:D223');
x=test(:,1);
y=test(:,2);
z=test(:,3);
groups=test(:,4);
figure(1),clf(1)
for g=1:max(groups)
L=groups==g;
scatter3(x(L),y(L),z(L),...
'DisplayName',sprintf('group %d',g));
hold on
end
hold off
legend
  3 comentarios
kenneth lee
kenneth lee el 13 de Mzo. de 2020
Hi so sorry for the late response, but is there a possibility to make all of them with different shapes and colors as i wan to distinctively reseperate them for better visualisation. Thanks alot for the follow up, really appreciate it! :)
Rik
Rik el 13 de Mzo. de 2020
If you don't want circles you can use plot3 instead of scatter3. Then you can set the LineSpec to whatever spec you like.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by