Home > omviz > clegend4.m

clegend4

PURPOSE ^

CLEGEND4 Plot color bar legend below a plot.

SYNOPSIS ^

function n = clegend4(z,label,width)

DESCRIPTION ^

CLEGEND4 Plot color bar legend below a plot.

    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,WIDTH) uses 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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Thu 01-Dec-2005 08:50:35 by m2html © 2003