I have some data
data = 16.9;23.8;11.3;5.8;9;2;8.6;7.3;2.6;0.3;0.9;2.7;1;8.7;4.5;0.4;2.8;8.9;0.4;5;2.7;8.4;3.9;8.8
I did a K-means clustering using this code:
[idx2,C2] = kmeans(firstblik,2,'Distance','cityblock','Replicates',10);
figure;
plot(firstblik(idx2==1),'r.','MarkerSize',12)
hold on
plot(firstblik(idx2==2),'b.','MarkerSize',12)
legend('Cluster 1','Cluster 2','Location','NW')
hold off
the idx2 automatically classifies my data in 2 groups (1 and 2) as such:
idx2 = [2;2;2;2;2;2;2;2;1;1;1;1;1;2;1;2;1;1;1;1;1;2;1;2]
I made a vector of labels for each one of these data points and I would like to show them on my plot.
I tried using the usual text() function for labeling but my k-means plot is split in 2:
I first plot all the 1's then all the 2's in the same figure
How do I label these points considering the labels follow the same order as my data matrix?
any help is appreciated
Thanks!
additional info: my plot is split in 2 so as I already mentioned the text() function won't work because the order of data isn't conserved when plotting idx2