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

3 visualizzazioni (ultimi 30 giorni)
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...

Risposta accettata

Rik
Rik il 23 Feb 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 Commenti
kenneth lee
kenneth lee il 13 Mar 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 il 13 Mar 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.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by