


CLEGEND4 Plot color bar legend below a plot.
modified 6/8/95 to allow fontzize control on label
CLEGEND4(Z) produces a color bar legend with axis Z.
The matrix Z is used to determine the minimum and maximum axis
labels for the color bar. The bar will be horizontal/vertical
depending on whether # rows </> # columns of Z.
CLEGEND4(Z,CLABEL) labels the axis of the color legend with the
string CLABEL. CLEGEND4(Z,CLABEL,FSIZE,WIDTH) uses FSIZE to specify
the label font size and WIDTH to specify
the fractional width of the main plot area. The default width is 0.83
If you want, say, CLEGEND to show N equally spaced colours then
create an N-color colormap.

0001 function n = clegend4(z,label,fsize,width) 0002 %CLEGEND4 Plot color bar legend below a plot. 0003 % 0004 % modified 6/8/95 to allow fontzize control on label 0005 % 0006 % CLEGEND4(Z) produces a color bar legend with axis Z. 0007 % The matrix Z is used to determine the minimum and maximum axis 0008 % labels for the color bar. The bar will be horizontal/vertical 0009 % depending on whether # rows </> # columns of Z. 0010 % 0011 % CLEGEND4(Z,CLABEL) labels the axis of the color legend with the 0012 % string CLABEL. CLEGEND4(Z,CLABEL,FSIZE,WIDTH) uses FSIZE to specify 0013 % the label font size and WIDTH to specify 0014 % the fractional width of the main plot area. The default width is 0.83 0015 % 0016 % If you want, say, CLEGEND to show N equally spaced colours then 0017 % create an N-color colormap. 0018 0019 % Clay M. Thompson 5-28-91 0020 % Copyright (c) 1991 by the MathWorks, Inc. 0021 % Fudged by me (RP) 9/jan/92 for beta 2, and again on 20/Mar/92 for 0022 % beta 3. 0023 0024 if nargin==0, z = [0:16]/16; end 0025 if nargin>=1, if isempty(z), z = [0:16]/16; end, end 0026 if nargin<3, fsize = 10; end; 0027 if nargin<4, width = .83; end; 0028 0029 [m,n] = size(z); 0030 0031 %if (m==1) | (n==1), 0032 % z = z(:)'; % Make sure it is a row vector 0033 % if (length(z)==2), 0034 % z = z(1) + [0:16]*(z(2)-z(1))/16; 0035 % end; 0036 %else 0037 zmin = min(z(z~=NaN)); 0038 zmax = max(z(z~=NaN)); 0039 % z=[zmin zmax]; 0040 z = zmin + [0:255]*(zmax-zmin)/255; % Generate 17 equally spaced points 0041 %end 0042 0043 clf; 0044 if (n>m), 0045 HH=axes('position',[.195 .15 .7 (1-width-.12)]); 0046 pcolor(z,[0 10]',[z;z]); 0047 HH=gca; 0048 set(HH,'position',[.195 .15 .7 (1-width-.12)]); 0049 caxis([min(z) max(z)]); 0050 shading('flat'); 0051 if nargin>=2, xlabel(label,'fontsize',fsize), end 0052 % Note use of undocumented 'sc' and 'fontsize' flags.... 0053 % text(.5,-2.5,[ 'WHOI Tomography Group: ' date],'sc','fontsize',10); 0054 set(gca,'tickdir','out','YTick',[]); 0055 % Set up subplot for main graph 0056 axes('position', [.12 (1-width+.15) .85 width-.23]); 0057 0058 else 0059 HH=axes('position',[.95-(1-width-.12) .15 (1-width-.12) .7]); 0060 pcolor([0 10],z,[z;z]'); 0061 HH=gca; 0062 set(HH,'position',[.95-(1-width-.12) .15 (1-width-.12) .7]); 0063 caxis([min(z) max(z)]); 0064 shading('flat'); 0065 if nargin>=2, ylabel(label,'fontsize',fsize), end 0066 % Note use of undocumented 'sc' and 'fontsize' flags.... 0067 % text(-2.5,-1.0,[ 'Signell-USGS: ' date],'sc','rotation',0,'fontsize',10); 0068 set(gca,'tickdir','out','XTick',[]); 0069 %,'ticklength',[.05 1] 0070 % Set up subplot for main graph 0071 axes('position', [.12 .12 .85-(1-width) .8]); 0072 end;