MATLAB: Give classes different marker colour and change fontsize of markers

fontsizemarkerscatter3

Hey everyone,
I am trying to make a scoreplot in matlab. I used PLS so it would be wise to divide the data into several classes and give every class a different markercolour. But up till now I've only managed to fill the makers and change the colour of all markers. I would like to give the classes, N,O-synthetic,O-natural,C and Cl different colours. In addition, I would like to know what the fastest way is to change the size of the datapoint labels (=text) without changing the fontsize of the whole figure.
Thank you!
x =
-0.0096
0.0145
0.0173
0.0207
-0.1068
-0.0997
0.0289
0.0020
-0.0033
0.0002
0.0177
0.0216
0.0380
0.0249
0.0270
0.0162
0.0136
0.0348
0.0487
0.0301
-0.0011
0.0135
-0.1698
0.0207
y =
-0.0384
-0.0137
-0.0580
-0.0660
0.0253
-0.0100
0.0509
-0.0396
-0.0448
-0.0243
-0.0168
0.0296
0.0562
0.0338
0.0575
0.0236
0.0139
-0.0071
0.0810
0.0121
-0.0213
-0.0457
0.0345
-0.0326
z =
-0.0753
0.0012
0.0518
0.0637
0.0136
0.0084
-0.0384
-0.0155
0.0006
-0.0187
0.0123
-0.0218
0.0515
-0.0284
-0.0490
-0.0410
-0.0363
0.0544
0.0850
0.0074
-0.0988
0.0126
0.0306
0.0302
names =
24×1 string array
"ABS450"
"BLITE450"
"BW450"
"CEL450"
"CLPE450"
"CP450"
"HDPE450"
"LATEX450"
"LIG450"
"NBR450"
"NYL11450"
"NYL66450"
"PBMA450"
"PC450"
"PEEK450"
"PET450"
"PI450"
"PLA450"
"PMMA450"
"PP450"
"PS450"
"PU450"
"PVC450"
"WS450"
class =
24×1 string array
"N-polymer"
"O-synthetic-polymer"
"O-natural-polymer"
"O-natural-polymer"
"Cl-polymer"
"Cl-polymer"
"C-polymer"
"C-polymer"
"O-synthetic-polymer"
"N-polymer"
"N-polymer"
"N-polymer"
"O-synthetic-polymer"
"O-synthetic-polymer"
"O-synthetic-polymer"
"C-polymer"
"N-polymer"
"O-synthetic-polymer"
"O-synthetic-polymer"
"C-polymer"
"C-polymer"
"N-polymer"
"Cl-polymer"
"O-natural polymer"
scatter3(x,y,z,'filled','MarkerFaceColor',[0 .75 .75]);
axis([-0.17 0.17 -0.1 0.1 -0.1 0.1]);
title('Score plot polymers 450 C');
xlabel('First Latent Variable');
ylabel('Second Latent Variable');
zlabel('third Latent Variable');
text(x,y,z,names);

Best Answer

x =[ -0.0096
0.0145
0.0173
0.0207
-0.1068
-0.0997
0.0289
0.0020
-0.0033
0.0002
0.0177
0.0216
0.0380
0.0249
0.0270
0.0162
0.0136
0.0348
0.0487
0.0301
-0.0011
0.0135
-0.1698
0.0207] ;
y =[ -0.0384
-0.0137
-0.0580
-0.0660
0.0253
-0.0100
0.0509
-0.0396
-0.0448
-0.0243
-0.0168
0.0296
0.0562
0.0338
0.0575
0.0236
0.0139
-0.0071
0.0810
0.0121
-0.0213
-0.0457
0.0345
-0.0326] ;
z = [ -0.0753
0.0012
0.0518
0.0637
0.0136
0.0084
-0.0384
-0.0155
0.0006
-0.0187
0.0123
-0.0218
0.0515
-0.0284
-0.0490
-0.0410
-0.0363
0.0544
0.0850
0.0074
-0.0988
0.0126
0.0306
0.0302] ;
names = { "ABS450"
"BLITE450"
"BW450"
"CEL450"
"CLPE450"
"CP450"
"HDPE450"
"LATEX450"
"LIG450"
"NBR450"
"NYL11450"
"NYL66450"
"PBMA450"
"PC450"
"PEEK450"
"PET450"
"PI450"
"PLA450"
"PMMA450"
"PP450"
"PS450"
"PU450"
"PVC450"
"WS450"} ;
class = {"N-polymer"
"O-synthetic-polymer"
"O-natural-polymer"
"O-natural-polymer"
"Cl-polymer"
"Cl-polymer"
"C-polymer"
"C-polymer"
"O-synthetic-polymer"
"N-polymer"
"N-polymer"
"N-polymer"
"O-synthetic-polymer"
"O-synthetic-polymer"
"O-synthetic-polymer"
"C-polymer"
"N-polymer"
"O-synthetic-polymer"
"O-synthetic-polymer"
"C-polymer"
"C-polymer"
"N-polymer"
"Cl-polymer"
"O-natural polymer"} ;
% scatter3(x,y,z,'filled','MarkerFaceColor',[0 .75 .75]);
s = (1:length(x))*10 ;
figure; scatter3( x, y, z, s, rand(length(x), 3 ), 'filled' )
axis([-0.17 0.17 -0.1 0.1 -0.1 0.1]);
title('Score plot polymers 450 C');
xlabel('First Latent Variable');
ylabel('Second Latent Variable');
zlabel('third Latent Variable');
text(x,y,z,names,'FontSize',12);