Home > FMAToolbox > Plot > clim.m

clim

PURPOSE ^

clim - Get or set color scaling limits for current axes (or all figure axes).

SYNOPSIS ^

function c = clim(handle,clims)

DESCRIPTION ^

clim - Get or set color scaling limits for current axes (or all figure axes).

  USAGE

    clims = clim
    clim(h)
    clim([c0 c1])
    clim(fig,[c0 c1])

    h              optional axes or figure handle (default = gca)
    c0, c1         optional scaling minimum and maximum

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function c = clim(handle,clims)
0002 
0003 %clim - Get or set color scaling limits for current axes (or all figure axes).
0004 %
0005 %  USAGE
0006 %
0007 %    clims = clim
0008 %    clim(h)
0009 %    clim([c0 c1])
0010 %    clim(fig,[c0 c1])
0011 %
0012 %    h              optional axes or figure handle (default = gca)
0013 %    c0, c1         optional scaling minimum and maximum
0014 
0015 
0016 % Copyright (C) 2009-2013 by Michaƫl Zugaro
0017 %
0018 % This program is free software; you can redistribute it and/or modify
0019 % it under the terms of the GNU General Public License as published by
0020 % the Free Software Foundation; either version 3 of the License, or
0021 % (at your option) any later version.
0022 
0023 switch(nargin),
0024     case 0,
0025         % Return clim for current axes
0026         c = get(gca,'CLim');
0027     case 1,
0028         if isdscalar(handle),
0029             % Return clim for the given axes
0030             if ~ishandle(handle),
0031                 error('Incorrect handle (type ''help <a href="matlab:help clim">clim</a>'' for details).');
0032             end
0033             c = get(handle,'CLim');
0034         else
0035             % Set clim for current axes
0036             clims = handle;
0037             if ~isdvector(clims,'<'),
0038                 error('Incorrect color limits (type ''help <a href="matlab:help clim">clim</a>'' for details).');
0039             end
0040             set(gca,'CLim',clims);
0041         end
0042     case 2,
0043         if ~isdscalar(handle) || ~ishandle(handle),
0044             error('Incorrect handle (type ''help <a href="matlab:help clim">clim</a>'' for details).');
0045         end
0046         if ~isdvector(clims,'<'),
0047             error('Incorrect color limits (type ''help <a href="matlab:help clim">clim</a>'' for details).');
0048         end
0049         % Set clim for axes or figure
0050         c = clims;
0051         if strcmp(get(handle,'type'),'figure'),
0052             % Set clim for all axes of a figure
0053             children = get(handle,'children');
0054             for i = 1:length(children),
0055                 child = children(i);
0056                 if strcmp(get(child,'type'),'axes'),
0057                     set(child,'CLim',clims);
0058                 end
0059             end
0060         else
0061             % Set clim for these axes
0062             set(handle,'CLim',clims);
0063         end
0064     end
0065 end

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005