Reputation: 57
I'm new to Matlab, and have some difficult to generate a "Multi Color" graph. I'm reading data from a text file into three vectors: X, Y and Cluster. I need to generate a graph for X and Y and to set the color of the point according to the cluster {0,1,2}. Can you please advise how can I do that? From what I tried to do, it only gives me an option to draw a plot by X,Y with one color.
Thanks in advance, Adi
Upvotes: 2
Views: 281
Reputation: 114786
It seems like you are trying to do a scatter plot
cmp = lines(3);
scatter( X, Y, 20, cmp(Cluster+1), 'filled');
note the +1
when indexing cmp
- Matlab's first index is 1 and not 0!
Upvotes: 1