Plot vectors with labels in matlab

Posted by mad on Stack Overflow See other posts from Stack Overflow or by mad
Published on 2013-11-11T14:28:30Z Indexed on 2013/11/11 15:54 UTC
Read the original article Hit count: 243

Filed under:
|
|

I have a Nx62 matrix with N 62-D vectors and a NX1 vector with the labels for the vectors. I am trying to plot these vectors with their labels because I want to see the behavior of these classes when plotted in a 62-dimensional space. The vectors belong to three classes according to the labels of a NX1 vector cited before.

How to to that in matlab? when i do plot(vector,classes) the result is very weird to analyse, how to put labels in the graph?

The code i am using to get the labels, vectors and plotting is the following:

%labels is a vector with labels, vectors is a matrix where each line is a vector
[labels,vectors]=libsvmread('features-im1.txt');

when I plot a three dimensional vector is simple

a=[1,2,3]
plot(a)

and then I get the result

Simple plot

but now i have a set of vectors and a set of labels, and i want to see the distribution of them, i want to plot each of these labels but also want to identify their classes. How to do that in matlab?

EDIT: This code is almost working. The problem is the fact that for each vector and class the plot will assign a color. I just want three colors and three labels, one per class.

[class,vector]=libsvmread('features-im1.txt'); 
%the plot doesn't allow negative and 0 values in the label 
class=class+2; 
labels = {'class -1','class 0','class 1'}; 
h = plot(vector); 
legend(h,labels{class})   

© Stack Overflow or respective owner

Related posts about matlab

Related posts about vector