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