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