%miasta
load cities
whos
subplot(2,3,1)
boxplot(ratings,'notch','off','symbol','b+','orientation','horizontal')
set(gca,'YTicklabel',categories)
%0,'+',0)
%set(gca,'Ticklabel',categories)
stdr=std(ratings);
sr=ratings./repmat(stdr,329,1);


subplot(2,3,4)
boxplot(sr,'notch','off','symbol','b+','orientation','horizontal')
set(gca,'YTicklabel',categories)

[vec, newdata, variances, t2]=princomp(sr);
vec(:,1:3)

subplot(1,3,2)
plot(newdata(:,1),newdata(:,2),'b+')
xlabel('1nd Principal Component')
ylabel('2nd Principal Component')
gname(names)



subplot(2,3,3)
pr_exp=100*variances/sum(variances)
%[A HX]=pareto(pr_exp);
pareto(pr_exp)


xlabel('Czynnik glowny')
ylabel('Wyjasniona warjancja %')

subplot(2,3,6)
hist(t2,30)
title('histogram wartosci t2')

[st2,index]=sort(t2);
index(end)
%names(index(end),:)
names(index(end-1:end),:)

% new_sr=sr;
% new_sr(index(end-1:end))=[];
% new_names=names;
% new_names(index(end-1:end))=[];
% new_ratings=ratings;
% new_ratings(index(end-1:end),:)=[];
% figure(2)
% 
% [ Loadings, specificVar, T, stats]=factoran(sr,6,'rotate','promax');
% subplot(121)
% plot(Loadings (:,1),Loadings (:,2),'b.' )
% text( Loadings (:,1),Loadings (:,2),num2str((1:10)'))
% xlabel('czynnik 1')
% ylabel('czynnik 2')
% grid
% xlim([-1 1])
% ylim([-1 1])
% axis square
% 
% subplot(2,3,1)
% boxplot(new_ratings,'notch','off','symbol','b+','orientation','horizontal')
% set(gca,'YTicklabel',categories)
% %0,'+',0)
% %set(gca,'Ticklabel',categories)
% %stdr=std(ratings);
% %sr=ratings./repmat(stdr,329,1);
% 
% 
% subplot(2,3,4)
% boxplot(new_sr,'notch','off','symbol','b+','orientation','horizontal')
% set(gca,'YTicklabel',categories)
% 
% [new_vec, new_newdata, new_variances, new_t2]=princomp(new_sr);
% new_vec(:,1:3)
% 
% subplot(1,3,2)
% plot(new_newdata(:,1),new_newdata(:,2),'b+')
% xlabel('1nd Principal Component')
% ylabel('2nd Principal Component')
% gname(new_names)
% 
% subplot(2,3,3)
% new_pr_exp=100*new_variances/sum(new_variances)
% %[A HX]=pareto(pr_exp);
% pareto(new_pr_exp)
% 
% 
% xlabel('Czynnik glowny')
% ylabel('Wyjasniona warjancja %')
% 
% subplot(2,3,6)
% hist(new_t2,30)
% title('histogram wartosci t2')
% 
% [new_st2,new_index]=sort(new_t2);
% new_index(end)
% names(new_index(end),:)
% names(new_index(end-1:end),:)
