wolffd@0
|
1 function som_projections_plot(pmode,varargin)
|
wolffd@0
|
2
|
wolffd@0
|
3 % SOM_PROJECTIONS_PLOT Projection visualizations.
|
wolffd@0
|
4 %
|
wolffd@0
|
5 % som_projections_plot(pmode,varargin)
|
wolffd@0
|
6 %
|
wolffd@0
|
7 % [cPCAarg, Pdata, Pproto] = som_projections(D,sM);
|
wolffd@0
|
8 % som_projections_plot('scatter',Pdata(:,1:3))
|
wolffd@0
|
9 % som_projections_plot('scatter',Pproto(:,1:3),Pproto(:,5:7),5,sM)
|
wolffd@0
|
10 % som_projections_plot('residuals',Pdata(:,1:4))
|
wolffd@0
|
11 % som_projections_plot('scree',cPCAarg{3})
|
wolffd@0
|
12 %
|
wolffd@0
|
13 % The other arguments depend on the pmode:
|
wolffd@0
|
14 %
|
wolffd@0
|
15 % pmode = 'scatter'
|
wolffd@0
|
16 %
|
wolffd@0
|
17 % arg1: Co (matrix) coordinates
|
wolffd@0
|
18 % arg2: color (matrix) color vectors
|
wolffd@0
|
19 % (string) colorstring ('k' by default)
|
wolffd@0
|
20 % arg3: psize (scalar) point size
|
wolffd@0
|
21 % arg4: sT (struct) topology struct, if map grid is drawn
|
wolffd@0
|
22 %
|
wolffd@0
|
23 % pmode = 'residuals'
|
wolffd@0
|
24 %
|
wolffd@0
|
25 % arg1: Co (matrix) coordinates (2 first columns) + residuals (the rest)
|
wolffd@0
|
26 % arg2: color (string) colorstring ('k' by default)
|
wolffd@0
|
27 %
|
wolffd@0
|
28 % pmode = 'scree'
|
wolffd@0
|
29 %
|
wolffd@0
|
30 % arg1: eigval (vector) vector of eigenvalues
|
wolffd@0
|
31 %
|
wolffd@0
|
32 % See also SOM_PROJECTIONS.
|
wolffd@0
|
33
|
wolffd@0
|
34 switch pmode,
|
wolffd@0
|
35 case 'scatter',
|
wolffd@0
|
36 Co = varargin{1};
|
wolffd@0
|
37 if length(varargin)>1, color = varargin{2}; else color = 'k'; end
|
wolffd@0
|
38 if length(varargin)>2, psize = varargin{3}; else psize = 5; end
|
wolffd@0
|
39 if length(varargin)>3, sT = varargin{4}; else sT = []; end
|
wolffd@0
|
40 if isstruct(sT) & strcmp(sT.type,'som_map'), sT = sT.topol; end
|
wolffd@0
|
41
|
wolffd@0
|
42 if isempty(sT),
|
wolffd@0
|
43 som_grid({'rect',[size(Co,1) 1]},'Coord',Co,'Markercolor',color,'line','none','markersize',psize);
|
wolffd@0
|
44 else
|
wolffd@0
|
45 if ischar(color), lcolor = color; else lcolor = 'k'; end
|
wolffd@0
|
46 som_grid(sT,'Coord',Co,'Markercolor',color,'markersize',psize,'linecolor',lcolor);
|
wolffd@0
|
47 end
|
wolffd@0
|
48
|
wolffd@0
|
49 case 'residuals',
|
wolffd@0
|
50 CoRes = varargin{1};
|
wolffd@0
|
51 n = size(CoRes,1);
|
wolffd@0
|
52 if length(varargin)>1, color = varargin{2}; else color = 'k'; end
|
wolffd@0
|
53 Co = CoRes(:,1:2); Co(end+1,:) = NaN;
|
wolffd@0
|
54 res = sqrt(sum(CoRes(:,3:end).*CoRes(:,3:end),2));
|
wolffd@0
|
55 h=plot(Co(:,1),Co(:,2),'k.'); set(h,'color',color);
|
wolffd@0
|
56 Co(end+1,:) = NaN;
|
wolffd@0
|
57 res = [res; 0; NaN];
|
wolffd@0
|
58 i = [1:n; 1:n; (n+1)+zeros(1,n)]; i = i(:);
|
wolffd@0
|
59 j = [(n+1)+zeros(1,n); 1:n; (n+2)+zeros(1,n)]; j = j(:);
|
wolffd@0
|
60 h = line(Co(i,1),Co(i,2),res(j)); set(h,'color',color);
|
wolffd@0
|
61 axis tight, axis equal, view(3)
|
wolffd@0
|
62
|
wolffd@0
|
63 case 'scree',
|
wolffd@0
|
64 eigval = varargin{1};
|
wolffd@0
|
65 if size(eigval,1)>1, eigval = eigval'; end
|
wolffd@0
|
66 eigval = eigval / sum(eigval);
|
wolffd@0
|
67 cumeig = cumsum(eigval);
|
wolffd@0
|
68 bar(cumeig,0.1)
|
wolffd@0
|
69 i = find(cumeig>=0.75); i75 = i(1);
|
wolffd@0
|
70 hold on
|
wolffd@0
|
71 plot([0 2],cumeig([2 2]),'r-',[0 i75],cumeig([i75 i75]),'r-');
|
wolffd@0
|
72 set(gca,'YTick',unique([0:0.1:1 cumeig(2) cumeig(i75)]));
|
wolffd@0
|
73 axis tight, grid on
|
wolffd@0
|
74
|
wolffd@0
|
75 end
|
wolffd@0
|
76
|