comparison toolboxes/MIRtoolbox1.3.2/somtoolbox/som_projections_plot.m @ 0:e9a9cd732c1e tip

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