Home > FMAToolbox > Plot > PlotColorCurves.m

PlotColorCurves

PURPOSE ^

PlotColorCurves - Plot a series of curves as an aggregated color map.

SYNOPSIS ^

function PlotColorCurves(curves,range,varargin)

DESCRIPTION ^

PlotColorCurves - Plot a series of curves as an aggregated color map.

  Plot a series of curves as an aggregated color map. In addition, one or more
  reference x locations can be represented as vertical lines: examples include
  time zero for cross-correlograms, baseline frequency for power spectra, etc.
  Finally, colored markers can mark locations of interest on each individual
  curve: examples include local minima, zero crossings, etc.

  USAGE

    PlotColorCurves(curves,range,x1,style1,x2,style2,...,<options>)

    curves         MxN matrix consisting of M curves (N bins each)
    range          optional x values for first and last bin centers
                   (if subsequent parameters are provided, this is
                   no longer optional)
    x1,x2...       optional locations of interest (see below)
    style1...      optional drawing style, e.g. 'w--', 'k.', etc.
    <options>      optional list of property-value pairs (see table below)

    =========================================================================
     Properties    Values
    -------------------------------------------------------------------------
     'cutoffs'     lower and upper cutoff values ([] = autoscale, default)
     'hgamma'      gamma-like correction for hue (1 = no correction, default)
     'colorspace'  'HSV' or 'RGB' (default = 'RGB')
     'bar'         draw a color bar (default = 'off')
     'type'        either 'linear' or 'circular' (default 'linear')
    =========================================================================

  NOTE

    Locations of interest can be either scalar values (for vertical lines) or
    vectors of length M (for individual markers).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function PlotColorCurves(curves,range,varargin)
0002 
0003 %PlotColorCurves - Plot a series of curves as an aggregated color map.
0004 %
0005 %  Plot a series of curves as an aggregated color map. In addition, one or more
0006 %  reference x locations can be represented as vertical lines: examples include
0007 %  time zero for cross-correlograms, baseline frequency for power spectra, etc.
0008 %  Finally, colored markers can mark locations of interest on each individual
0009 %  curve: examples include local minima, zero crossings, etc.
0010 %
0011 %  USAGE
0012 %
0013 %    PlotColorCurves(curves,range,x1,style1,x2,style2,...,<options>)
0014 %
0015 %    curves         MxN matrix consisting of M curves (N bins each)
0016 %    range          optional x values for first and last bin centers
0017 %                   (if subsequent parameters are provided, this is
0018 %                   no longer optional)
0019 %    x1,x2...       optional locations of interest (see below)
0020 %    style1...      optional drawing style, e.g. 'w--', 'k.', etc.
0021 %    <options>      optional list of property-value pairs (see table below)
0022 %
0023 %    =========================================================================
0024 %     Properties    Values
0025 %    -------------------------------------------------------------------------
0026 %     'cutoffs'     lower and upper cutoff values ([] = autoscale, default)
0027 %     'hgamma'      gamma-like correction for hue (1 = no correction, default)
0028 %     'colorspace'  'HSV' or 'RGB' (default = 'RGB')
0029 %     'bar'         draw a color bar (default = 'off')
0030 %     'type'        either 'linear' or 'circular' (default 'linear')
0031 %    =========================================================================
0032 %
0033 %  NOTE
0034 %
0035 %    Locations of interest can be either scalar values (for vertical lines) or
0036 %    vectors of length M (for individual markers).
0037 %
0038 
0039 % Copyright (C) 2012-2013 by Michaƫl Zugaro
0040 %
0041 % This program is free software; you can redistribute it and/or modify
0042 % it under the terms of the GNU General Public License as published by
0043 % the Free Software Foundation; either version 3 of the License, or
0044 % (at your option) any later version.
0045 
0046 colors = 'kbgrw';
0047 
0048 % Check number of parameters
0049 if nargin < 1,
0050   error('Incorrect number of parameters (type ''help <a href="matlab:help PlotColorCurves">PlotColorCurves</a>'' for details).');
0051 end
0052 
0053 % Check parameters
0054 if ~isdmatrix(curves),
0055     error('Incorrect curves (type ''help <a href="matlab:help PlotColorCurves">PlotColorCurves</a>'' for details).');
0056 end
0057 if nargin < 2,
0058     range = [0 size(curves,2)];
0059 elseif ~isdvector(range,'#2','<'),
0060     error('Incorrect range (type ''help <a href="matlab:help PlotColorCurves">PlotColorCurves</a>'' for details).');
0061 end
0062 
0063 options = {};
0064 last = length(varargin);
0065 % Parse parameter list: find options for PlotColorMap
0066 for i = 1:length(varargin),
0067     if ischar(varargin{i}),
0068         switch(lower(varargin{i})),
0069             case {'cutoffs','gamma','hgamma','colorspace','bar','type'},
0070                 options = {varargin{i:end}};
0071                 last = i-1;
0072                 break;
0073         end
0074     end
0075 end
0076 
0077 % Plot color curves
0078 [m,n] = size(curves);
0079 if isempty(options),
0080     PlotColorMap(curves,'x',linspace(range(1),range(2),n));
0081 else
0082     PlotColorMap(curves,'x',linspace(range(1),range(2),n),options{:});
0083 end
0084 hold on;
0085 
0086 i = 1;
0087 c = 1;
0088 while i <= last,
0089     x = varargin{i};
0090     if isdscalar(x),
0091         if i+1 <= length(varargin) && ischar(varargin{i+1}),
0092             style = varargin{i+1};
0093             PlotHVLines(x,'v',style);
0094             i = i + 2;
0095         else
0096             PlotHVLines(x,'v','w--');        
0097             i = i + 1;
0098         end
0099     elseif isdvector(x,['#' int2str(m)]),
0100         if i+1 <= length(varargin) && ischar(varargin{i+1}),
0101             style = varargin{i+1};
0102             plot(x,1:m,style,'markersize',8);
0103             i = i + 2;
0104         else
0105             plot(x,1:m,['.' colors(k)],'markersize',8);
0106             i = i + 1;            
0107             k = k + 1;
0108             if k > length(colors), k = 1; end
0109         end
0110     else
0111         error('Incorrect locations (type ''help <a href="matlab:help PlotColorCurves">PlotColorCurves</a>'' for details).');    
0112     end
0113 end

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