I have a matrix points X in 3 dimensions (X is a Nx3 matrix) and those points belong to clusters. The cluster it belongs is given by the Nx1 vector Cluster (it has values like 1,2,3,…). So, I am plotting it on scatter3 like this:
scatter3(X(:,1),X(:,2),X(:,3),15,Cluster)
It works fine, but I would like to add a legend to it, showing the colored markers and the cluster it represents.
For example, if i have 3 clusters, I would like to have a legend like:
<blue o> - Cluster 1
<red o> - Cluster 2
<yellow o> - Cluster 3
Thank you very much for the help!
Instead of using
scatter3, I suggest you useplot3, which will make labeling much simpler: