| plotdata_bylabels(data,classlabel,pc,subp,m,A1,A2,B1,B2,A3,B3) |
function D = plotdata_bylabels(data,classlabel,pc,subp,m,A1,A2,B1,B2,A3,B3)
% plotting data in first two principle components (pc) or dimensions
% and showing their class labels if given
% pc = 1/2: using two principle components; 3: three principle components
% data: row -- samples, column --- dimensions
if nargin<3
pc=0;
subp=0;
m='co';
end
if subp
subplot(2,2,subp);
box on; cla;
end
dim = size(data,2);
if dim > 2 && pc > 0
if pc >= 3
D = pca_of_data(data',pc);
else
D = pca_of_data(data',2);
end
D = D';
else
D = data;
end
if 0 % plotting the data only in classes 1 & 4
Ds = D; D = Ds(:,[4 5]);
R = (classlabel>1).*(classlabel<4);
R=find(R);
D(R,:)=[];
classlabel(R)=[];
clf;show2dim_byclass(D,classlabel,m);
xlabel('PC4','FontSize',11,'FontWeight','demi');
ylabel('PC5','FontSize',11,'FontWeight','demi');
legend('class 1','class 4',1);
end
if pc <= 3
if pc == 0
D = D(:,1:2);
end
%plot3(D(:,1),D(:,2),D(:,3),'k.');
show2dim_byclass(D,classlabel,m);
if dim > 2 && pc > 0
xlabel('PC1','FontSize',11,'FontWeight','demi');
ylabel('PC2','FontSize',11,'FontWeight','demi');
else
xlabel('X','FontSize',11,'FontWeight','demi');
ylabel('Y','FontSize',11,'FontWeight','demi');
end
elseif pc > 3 && nargin > 5
%show the border/central regions of two clusters
%plot(D(:,1),D(:,2),'k.'); hold on;
plot(D(A1,1),D(A1,2),'rs'); hold on;
plot(D(A2,1),D(A2,2),'mo'); hold on;
if length(A3)>0
plot(D(A3,1),D(A3,2),'cs'); hold on;
end
plot(D(B1,1),D(B1,2),'b^'); hold on;
plot(D(B2,1),D(B2,2),'g*'); hold on;
if length(B3)>0
plot(D(B3,1),D(B3,2),'c^'); hold on;
end
end
[fd,dt] = max(D(:,1));
[ft, dt] = min(D(:,1));
dt = 0.05*(fd-ft); %0.5
xlim([ft-dt fd+dt]);
[fd,dt] = max(D(:,2));
[ft, dt] = min(D(:,2));
dt = 0.05*(fd-ft); %0.5
ylim([ft-dt fd+dt]);
|
|