Home > atmlab > graphs > colorspec.m

colorspec

PURPOSE ^

COLORSPEC Extracts color specifications.

SYNOPSIS ^

function [cranges,cmap] = colorspec(h)

DESCRIPTION ^

 COLORSPEC   Extracts color specifications.

    A help function to handle Matlab's treatment of colors. This function
    returns the color map as *colormap*, but also the data range
    corresponding to each color: *cranges*.

    *cranges* is a matrix with two columns, with nas many rows as *cmap*.
    Color i (row i in *cmap*) is used for the data range:
      [cranges(i,1),cranges(i,2)[

 FORMAT   [cranges,cmap] = colorspec(h)
        
 OUT   cranges   Color ranges. See above.
       cmap      Color map, as returned by *colormap*.
 OPT   h         Axis hanlde. Default is *gca*.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

colorspec.m

SOURCE CODE ^

0001 % COLORSPEC   Extracts color specifications.
0002 %
0003 %    A help function to handle Matlab's treatment of colors. This function
0004 %    returns the color map as *colormap*, but also the data range
0005 %    corresponding to each color: *cranges*.
0006 %
0007 %    *cranges* is a matrix with two columns, with nas many rows as *cmap*.
0008 %    Color i (row i in *cmap*) is used for the data range:
0009 %      [cranges(i,1),cranges(i,2)[
0010 %
0011 % FORMAT   [cranges,cmap] = colorspec(h)
0012 %
0013 % OUT   cranges   Color ranges. See above.
0014 %       cmap      Color map, as returned by *colormap*.
0015 % OPT   h         Axis hanlde. Default is *gca*.
0016 
0017 % 2007-03-12   Created by Patrick Eriksson.
0018 
0019 
0020 function [cranges,cmap] = colorspec(h)
0021   
0022 if nargin == 0
0023   h = gca;
0024 end
0025 
0026 clims = caxis;
0027 cmap  = colormap;
0028 
0029 x = linspace( clims(1), clims(2), size(cmap,1)+1 );
0030 
0031 cranges = [ [ -Inf x(2:end-1)]' [x(2:end-1) Inf]' ];
0032

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005