Home > FR3DSource > zGraphDistanceMatrix.m

zGraphDistanceMatrix

PURPOSE ^

zClusterGraph(D,Lab,W) treats D as the distances between instances with labels given by Lab. It displays the distances graphically. W is the number of characters of Lab to use.

SYNOPSIS ^

function [void] = zGraphDistanceMatrix(D,Lab,W,Table)

DESCRIPTION ^

 zClusterGraph(D,Lab,W) treats D as the distances between instances with labels given by Lab.  It displays the distances graphically.  W is the number of characters of Lab to use.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % zClusterGraph(D,Lab,W) treats D as the distances between instances with labels given by Lab.  It displays the distances graphically.  W is the number of characters of Lab to use.
0002 
0003 function [void] = zGraphDistanceMatrix(D,Lab,W,Table)
0004 
0005 [s,t] = size(D);
0006 
0007 NoLabel = 0;
0008 
0009 if (nargin < 2) || (length(Lab) == 0),
0010   for i = 1:s,
0011     Lab{i} = '    ';
0012   end
0013   W = 1;
0014   NoLabel = 1;
0015 end  
0016 
0017 if nargin < 3,
0018   W = length(Lab{1});
0019   for i = 1:s,
0020     W = min(length(Lab{i}),W);
0021   end
0022 end  
0023 
0024 if nargin < 4,
0025   Table = 0;
0026 end
0027 
0028 % ------------------------------------------ Print table
0029 
0030 if Table == 1,
0031   fprintf('                             ');
0032   for j=1:t,
0033     w = min(length(Lab{j}), 6);
0034     fprintf('%6s', Lab{j}(1:w));
0035   end
0036   fprintf('\n');
0037   for i=1:s,
0038     fprintf('%24s ', Lab{i}(1:28));
0039     for j= 1:t,
0040       fprintf('%5.2f ', D(i,j));
0041     end
0042     fprintf('\n');
0043   end
0044   fprintf('\n');
0045 end
0046 
0047 % ------------------------------------------ Display graph of isodiscrepancies
0048 
0049 DD = zeros(s+1,t+1);           % pad with zeros
0050 DD(1:s,1:t) = D;
0051 
0052 pcolor(real(DD))
0053 
0054 %pcolor(2*floor(DD/2))
0055 
0056 shading flat
0057 axis ij
0058 view(2)
0059 %colormap('default');
0060 %map = colormap;
0061 %map = map((end-8):-1:8,:);
0062 %map = map((end-8):-1:end,:);
0063 %colormap(map);
0064 %caxis([0 16]);
0065 %colorbar('location','eastoutside');
0066 
0067 if Table > 0,
0068   for i = 1:s,
0069     for j = 1:s,
0070       tt = sprintf('%3.1f',DD(i,j));
0071       text(i+0.5,j+0.5,tt,'HorizontalAlignment','Center');
0072     end
0073   end
0074 end
0075 
0076 for i = 1:t,
0077   SLab{i} = Lab{i}(1:min(length(Lab{i}),W(1)));
0078 end
0079 
0080 if length(W) > 1,
0081   for i = 1:t,
0082     SSLab{i} = Lab{i}(1:W(2));
0083   end
0084 end
0085 
0086 if (length(Lab) < 20) || (NoLabel == 1),
0087   FS = 10;
0088 elseif length(Lab) < 50,
0089   FS = 8;
0090 elseif length(Lab) < 80,
0091   FS = 4;
0092 elseif length(Lab) < 100,
0093   FS = 3;
0094 elseif length(Lab) < 300,
0095   FS = 2;
0096 elseif length(Lab) < 400,
0097   FS = 1;
0098 else
0099   FS = 0.5;
0100 end
0101 
0102 FS = 8;
0103 
0104 if length(W) > 1,
0105   set(gca,'XTick',(1:s)+0.5)
0106   set(gca,'XTickLabel',SSLab,'FontSize',FS)
0107 else
0108   XFS = min(6,FS);
0109   for i = 1:t,
0110     text(i+0.5,t+1,SLab{i},'Rotation',90,'HorizontalAlignment','right','FontSize',XFS);
0111   end
0112   set(gca,'XTickLabel',[])
0113 end
0114 
0115 set(gca,'YTick',(1:s)+0.5)
0116 set(gca,'YTickLabel',SLab,'FontSize',FS)
0117 
0118 %set(gca,'OuterPosition',[0.1 0.1 1.1 1.1]); % doesn't help with pdf file!

Generated on Fri 03-Apr-2009 09:52:35 by m2html © 2003