comparison toolboxes/MIRtoolbox1.3.2/somtoolbox/som_plotmatrix.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_plotmatrix(sM,D,Col,comps)
2
3 %SOM_PLOTMATRIX Visualize pairwise scatter plots and histograms.
4 %
5 % som_plotmatrix(sM,[sD],[Col],[comps])
6 %
7 % Input and output arguments ([]'s are optional):
8 % sM (struct) map struct
9 % [sD] (struct) data struct, corresponding to the map
10 % (matrix) data matrix (size dlen x dim)
11 % [Col] (matrix) size munits x 3, color for each map unit
12 % [comps] (vector) which components to plot (1:dim by default)
13 %
14 % See also: SOM_SHOW, SOM_ORDER_CPLANES.
15
16 % Copyright (c) 2000 by the SOM toolbox programming team.
17 % Contributed to SOM Toolbox on June 16th, 2000 by Juha Vesanto
18 % http://www.cis.hut.fi/projects/somtoolbox/
19
20 % Version 2.0beta juuso 140600
21
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55
23
24 % sM
25 [munits dim] = size(sM.codebook);
26 M = sM.codebook;
27
28 % sD
29 if nargin>1 & ~isempty(D),
30 if isstruct(D), D = D.data; end
31 bmus = som_bmus(sM,D);
32 else D = []; bmus = [];
33 end
34
35 % Col
36 if nargin<3 | isempty(Col), Col = som_colorcode(sM); end
37 if ischar(Col), Col = som_colorcode(sM,Col); end
38
39 % comps
40 if nargin<4 | isempty(comps), comps = 1:dim; end
41 n = length(comps)+1;
42
43 % histogram bins
44 if ~isempty(D), C=D; else C=M; end
45 cHbins = cell(dim,1);
46 cAxis = cell(dim,1);
47 for i=1:dim,
48 if ~isempty(D), mima = [min(D(:,i)),max(D(:,i))];
49 else mima = [min(M(:,i)),max(M(:,i))];
50 end
51 cAxis{i} = mima;
52 [dummy,cHbins{i}] = hist(mima,20);
53 end
54
55 nt = 4; % number of ticks in scatter plots
56
57 % visualization
58 clf
59 for i=1:n,
60 for j=1:n,
61 subplot(n,n,(i-1)*n+j);
62 if j==1 & i==1,
63 h=som_cplane(sM,Col); set(h,'edgecolor','none')
64 elseif i==1,
65 ind = comps(j-1);
66 b = cHbins{ind};
67 hs = hist(M(:,ind),b);
68 h = bar(b,hs,0.8); set(h,'EdgeColor','none','FaceColor','k');
69 axis on, axis tight
70 set(gca,'XTick',[],'Box','on');
71 title(sM.comp_names{ind});
72 elseif j==1,
73 ind = comps(i-1);
74 if ~isempty(D),
75 b = cHbins{ind};
76 hs = hist(D(:,ind),b);
77 h = bar(b,hs,0.8); set(h,'EdgeColor','none','FaceColor','k');
78 axis on, axis tight
79 set(gca,'XTick',[],'Box','on');
80 ylabel(sM.comp_names{ind})
81 else
82 text(0.5,0.5,sM.comp_names{ind});
83 axis off
84 end
85 elseif i==j,
86 ind = comps(i-1);
87 h=som_cplane(sM,M(:,ind));
88 set(h,'edgecolor','none')
89 a = cAxis{ind};
90 caxis(a); v = unique([a, min(M(:,ind)), max(M(:,ind))]);
91 vn=som_denormalize(v,sM.comp_norm{ind})';
92 h=colorbar('vert');
93 set(h,'YTick',v,'YTickLabel',cellstr(num2str(vn,2)));
94 elseif i<j | ~isempty(D),
95 if i>j, i1 = i-1; i2 = j-1; else i1 = j-1; i2 = i-1; end
96 ind1 = comps(i1); ind2 = comps(i2);
97 if i<j,
98 som_grid(sM,'coord',M(:,[ind1 ind2]),'markersize',2,'MarkerColor',Col);
99 else
100 som_grid('rect',[size(D,1) 1],'coord',D(:,[ind1 ind2]),...
101 'Line','none','MarkerColor',Col(bmus,:),'Markersize',2);
102 %cla; hold on
103 %for k=1:max(bmus),
104 % inds = find(bmus==k);
105 % if any(inds),
106 % som_grid('rect',[length(inds) 1],'coord',D(inds,[ind1 ind2]),...
107 % 'Line','none','MarkerColor',Col(k,:),'Markersize',2);
108 % end
109 %end
110 end
111 a = [cAxis{ind1} cAxis{ind2}]; axis(a);
112 x = linspace(a(1),a(2),nt); xn = som_denormalize(x,sM.comp_norm{ind1})';
113 set(gca,'XTick',x,'XTickLabel',cellstr(num2str(xn,2)));
114 y = linspace(a(3),a(4),nt); yn = som_denormalize(y,sM.comp_norm{ind2})';
115 set(gca,'YTick',y,'YTickLabel',cellstr(num2str(yn,2)));
116 xlabel(sM.comp_names{ind1}), ylabel(sM.comp_names{ind2})
117 end
118 end
119 end
120
121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55
122