Daniel@0: function som_plotmatrix(sM,D,Col,comps) Daniel@0: Daniel@0: %SOM_PLOTMATRIX Visualize pairwise scatter plots and histograms. Daniel@0: % Daniel@0: % som_plotmatrix(sM,[sD],[Col],[comps]) Daniel@0: % Daniel@0: % Input and output arguments ([]'s are optional): Daniel@0: % sM (struct) map struct Daniel@0: % [sD] (struct) data struct, corresponding to the map Daniel@0: % (matrix) data matrix (size dlen x dim) Daniel@0: % [Col] (matrix) size munits x 3, color for each map unit Daniel@0: % [comps] (vector) which components to plot (1:dim by default) Daniel@0: % Daniel@0: % See also: SOM_SHOW, SOM_ORDER_CPLANES. Daniel@0: Daniel@0: % Copyright (c) 2000 by the SOM toolbox programming team. Daniel@0: % Contributed to SOM Toolbox on June 16th, 2000 by Juha Vesanto Daniel@0: % http://www.cis.hut.fi/projects/somtoolbox/ Daniel@0: Daniel@0: % Version 2.0beta juuso 140600 Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55 Daniel@0: Daniel@0: % sM Daniel@0: [munits dim] = size(sM.codebook); Daniel@0: M = sM.codebook; Daniel@0: Daniel@0: % sD Daniel@0: if nargin>1 & ~isempty(D), Daniel@0: if isstruct(D), D = D.data; end Daniel@0: bmus = som_bmus(sM,D); Daniel@0: else D = []; bmus = []; Daniel@0: end Daniel@0: Daniel@0: % Col Daniel@0: if nargin<3 | isempty(Col), Col = som_colorcode(sM); end Daniel@0: if ischar(Col), Col = som_colorcode(sM,Col); end Daniel@0: Daniel@0: % comps Daniel@0: if nargin<4 | isempty(comps), comps = 1:dim; end Daniel@0: n = length(comps)+1; Daniel@0: Daniel@0: % histogram bins Daniel@0: if ~isempty(D), C=D; else C=M; end Daniel@0: cHbins = cell(dim,1); Daniel@0: cAxis = cell(dim,1); Daniel@0: for i=1:dim, Daniel@0: if ~isempty(D), mima = [min(D(:,i)),max(D(:,i))]; Daniel@0: else mima = [min(M(:,i)),max(M(:,i))]; Daniel@0: end Daniel@0: cAxis{i} = mima; Daniel@0: [dummy,cHbins{i}] = hist(mima,20); Daniel@0: end Daniel@0: Daniel@0: nt = 4; % number of ticks in scatter plots Daniel@0: Daniel@0: % visualization Daniel@0: clf Daniel@0: for i=1:n, Daniel@0: for j=1:n, Daniel@0: subplot(n,n,(i-1)*n+j); Daniel@0: if j==1 & i==1, Daniel@0: h=som_cplane(sM,Col); set(h,'edgecolor','none') Daniel@0: elseif i==1, Daniel@0: ind = comps(j-1); Daniel@0: b = cHbins{ind}; Daniel@0: hs = hist(M(:,ind),b); Daniel@0: h = bar(b,hs,0.8); set(h,'EdgeColor','none','FaceColor','k'); Daniel@0: axis on, axis tight Daniel@0: set(gca,'XTick',[],'Box','on'); Daniel@0: title(sM.comp_names{ind}); Daniel@0: elseif j==1, Daniel@0: ind = comps(i-1); Daniel@0: if ~isempty(D), Daniel@0: b = cHbins{ind}; Daniel@0: hs = hist(D(:,ind),b); Daniel@0: h = bar(b,hs,0.8); set(h,'EdgeColor','none','FaceColor','k'); Daniel@0: axis on, axis tight Daniel@0: set(gca,'XTick',[],'Box','on'); Daniel@0: ylabel(sM.comp_names{ind}) Daniel@0: else Daniel@0: text(0.5,0.5,sM.comp_names{ind}); Daniel@0: axis off Daniel@0: end Daniel@0: elseif i==j, Daniel@0: ind = comps(i-1); Daniel@0: h=som_cplane(sM,M(:,ind)); Daniel@0: set(h,'edgecolor','none') Daniel@0: a = cAxis{ind}; Daniel@0: caxis(a); v = unique([a, min(M(:,ind)), max(M(:,ind))]); Daniel@0: vn=som_denormalize(v,sM.comp_norm{ind})'; Daniel@0: h=colorbar('vert'); Daniel@0: set(h,'YTick',v,'YTickLabel',cellstr(num2str(vn,2))); Daniel@0: elseif ij, i1 = i-1; i2 = j-1; else i1 = j-1; i2 = i-1; end Daniel@0: ind1 = comps(i1); ind2 = comps(i2); Daniel@0: if i