PAIRS Pairwise scatter plots. CALL: pairs(X,label,sym) X = data label = character array or a cellarray of strings to label the plot sym = plotsymbol (default '.') The columns of X are plotted versus each other. On the diagonal there is a normal probability plot for every variable. Note: the order of label and sym is arbitrary Example X = rand(30,3); pairs(X,'*',{'wood','ply','none'})
Places text in figure window. | |
Control axis scaling and appearance. | |
Create character array (string). | |
Clear current figure. | |
Correlation coefficients. | |
Inverse error function. | |
Display message and abort function. | |
Get handle to current axis. | |
Hold current graph. | |
True for cell array. | |
Convert number to string. (Fast version) | |
Linear plot. | |
Set object properties. | |
Graph title. |
001 function J = pairs(X,varargin) 002 %PAIRS Pairwise scatter plots. 003 % 004 % CALL: pairs(X,label,sym) 005 % 006 % X = data 007 % label = character array or a cellarray of strings to label the plot 008 % sym = plotsymbol (default '.') 009 % 010 % The columns of X are plotted versus each other. On the diagonal there is 011 % a normal probability plot for every variable. 012 % 013 % Note: the order of label and sym is arbitrary 014 % 015 % Example 016 % X = rand(30,3); 017 % pairs(X,'*',{'wood','ply','none'}) 018 019 % Tested on matlab 5.x 020 % History 021 % revised pab 01.11.2000 022 % - updated help header to WAFO style 023 % - added N and correlation coefficient to the plot 024 % - added label 025 % - removed xtick and ytick from the axis 026 % Copyright (c) Anders Holtsberg 027 028 error(nargchk(1,3,nargin)) 029 030 plotsymbol = '.'; % default 031 labl =[]; 032 [n,p] = size(X); 033 034 for ix=1:nargin-1, 035 A = varargin{ix}; 036 if iscell(A), 037 labl = char(A); % transform to a character array 038 elseif size(A,1) == n 039 labl = A; 040 else 041 plotsymbol = A; 042 end 043 end 044 045 clf 046 X = X - ones(n,1)*min(X); 047 X = X ./ (ones(n,1)*max(X)); 048 X = X*0.8 + 0.1; 049 050 051 Z = zeros(p*p*n,2); 052 for i = 1:p 053 for j = 1:p 054 k = ((i-1)+(j-1)*p)*n+1; 055 if i~=j, 056 Z(k:k+n-1, 1) = X(:,i) + i-1; 057 Z(k:k+n-1, 2) = X(:,j) + p-j; 058 else 059 Z(k:k+n-1, 1) = sort(X(:,i)) + i-1; 060 xx = ((1:n)-1/2)'/n; 061 Z(k:k+n-1, 2) = erfinv(2*xx-1)/7 + 0.5 + p-j; 062 end 063 end 064 end 065 066 hold off 067 plot(Z(:,1), Z(:,2), plotsymbol) 068 axis([0 p 0 p]) 069 hold on 070 for i = 0:p 071 plot([0,p],[i,i],'-') 072 plot([i,i],[0,p],'-') 073 end 074 075 rho = corrcoef(X);% Put correlation coefficient in the plot 076 for i=1:p-1, 077 for j=i+1:p 078 figtext(i-1+0.01,p-j+0.01,['\rho = ' num2str(rho(i,j),2)],'data','data','left','bottom') 079 figtext(j-0.01,p-i+0.01,['\rho = ' num2str(rho(i,j),2 )],'data','data','right','bottom') 080 end 081 end 082 if ~isempty(labl) 083 for j=1:p, 084 set(gca,'DefaultTextRotation',90) 085 figtext(-.3,p-j+0.5,labl(j,:),'data','data','left','middle') 086 set(gca,'DefaultTextRotation',0) 087 figtext(j-0.5,-.3,labl(j,:),'data','data','center','bottom') 088 end 089 end 090 091 % Remove xtick and ytick 092 set(gca,'xtick',[],'ytick',[]) 093 hold off 094 title(['N = ' num2str(n)]) 095
Comments or corrections to the WAFO group