Plotting in Matlab by groups or (labels)

How to plot in Matlab by labels?
Suppose You have some data:
1st case – we have 1-d (dimension) data or vector, so the next step is to plot this vector:
>plot(data,'b*');

Matlab plot

Simple Plot


Now You’ve made some classification using f.e. kmeans algorithm:
>[IDX,C]=kmeans(data,5,'emptyaction','singleton');
So we have labels in vector IDX and centroids in C. Now let’s try to plot data-vector using labels
>scatter(1:1000, data, 30, IDX, 'filled');
scatter plot

scatter plot with lables


Let’s scale Y to log in order to see small values
Scatter plot with Y-log scale

Scatter plot with Y-log scale


The same thing we can make with 2-dimension data

VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)

Tags: ,
| September 6th, 2010 | Posted in Matlab, Software |

Leave a Reply

*