Home > classes > @ao > iplot.m

iplot

PURPOSE ^

IPLOT provides an intelligent plotting tool for LTPDA.

SYNOPSIS ^

function varargout = iplot(varargin)

DESCRIPTION ^

 IPLOT provides an intelligent plotting tool for LTPDA.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: IPLOT provides an intelligent plotting tool for LTPDA.

 CALL:               hfig = iplot (a,pl)
              [hfig, hax] = iplot (a,pl)
         [hfig, hax, hli] = iplot (a,pl)

 INPUTS:      pl   - a parameter list
              a    - input analysis object

 OUTPUTS:     hfig - handles to figures
              hax  - handles to axes
              hli  - handles to lines

 Plot parameters: 
 
             'type' - one of the data class types
                      'tsdata' [default], 'fsdata', 'cdata', 'xydata', 'xyzdata'.

             'Arrangement' - select the plot layout:
                           'single'   - plots all AOs on individual figures
                           'stacked'  - plots all AOs on the same axes [default]
                           'subplots' - plots all AOs on subplots
 
 Line parameters:
 
        The following properties take cell array values. If the length of 
        the cell array is shorter than the number of lines to plot, the 
        remaining lines will be plotted with the default options. If the
        cell array is of length 2 and the first cell contains the string
        'all', then the second cell is used to set the propery of all
        lines.
 
             'LineColors' - a cell array of color definitions for each line.
 
             'LineStyles' - a cell array of line styles. 
 
             'Markers'    - a cell array of markers. 
 
             'LineWidths' - a cell array of line widths. If the length of the
                            cell array is shorter than the number of lines to
                            plot, the remaining lines will be plotted with
                            the default line width.
 
 Axes parameters:
 
             'Legends' - specify a cell array of strings to be used for
                         the plot legends. If a cell contains an empty
                         string, the default legend string is built. 
                         If a single string 'off' is given instead of a
                         cell array, then the legends are all switched
                         off.
 
             'XLabels' - Specify the labels to be used on the x-axis. The
                         units are added from the data object 'xunits'
                         property.
 
             'YLabels' - Specify the labels to be used on the y-axis. The
                         units are added from the data object 'yunits'
                         property. If the object contains complex data,
                         you should specify two y-labels for that object.
 
    The following axis properties also work with the 'all' keyword as
    described above in the line properties section.
 
             'XScales' - Specify the scales to be used on the x-axes.
 
             'YScales' - Specify the scales to the used on the y-axes. If
                         an object contains complex data, you should 
                         specify two y-labels for that object.
 
             'XRanges' - Specify the ranges to be displayed on the x-axes.
 
             'YRanges' - Specify the ranges to the displayed on the
                         y-axes.
 
 
 VERSION:     $Id: iplot.m,v 1.25 2008/02/12 09:29:24 mauro Exp $

 EXAMPLES:
 
 1) Plot two time-series AOs with different colors, line styles, and widths
 
   pl = plist('Linecolors', {'g', 'k'}, 'LineStyles', {'', '--'}, 'LineWidths', {1, 4});
   iplot(tsao1, tsao2, pl);
 
 2) Plot two time-series AOs in subplots. Also overide the second legend
    text and the first line style.
 
   pl = plist('Arrangement', 'subplots', 'LineStyles', {'--'}, 'Legends', {'', 'My Sine Wave'});
   iplot(tsao1, tsao2, pl);
 
 3) Plot two time-series AOs taking the square of the y-values of the
    first AO and the log of the x-values of the second AO.
 
   pl = plist('Arrangement', 'subplots', 'YMaths', 'y.^2', 'XMaths', {'', 'log(x)'});
   iplot(tsao1, tsao2, pl);
 
 4) Plot two frequency-series AOs on subplots with the same Y-scales and
    Y-ranges
 
   pl1 = plist('Yscales', {'All', 'lin'});
   pl2 = plist('arrangement', 'subplots', 'YRanges', {'All', [1e-6 100]});
   iplot(fsd1, fsd2, pl1, pl2)
 
 
 The following call returns a parameter list object that contains the
 default parameter values:

 >> pl = iplot(ao, 'Params')

 The following call returns a string that contains the routine CVS version:

 >> version = iplot(ao,'Version')

 The following call returns a string that contains the routine category:

 >> category = iplot(ao,'Category')

 HISTORY: 22-12-07 M Hewitson
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = iplot(varargin)
0002 % IPLOT provides an intelligent plotting tool for LTPDA.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: IPLOT provides an intelligent plotting tool for LTPDA.
0007 %
0008 % CALL:               hfig = iplot (a,pl)
0009 %              [hfig, hax] = iplot (a,pl)
0010 %         [hfig, hax, hli] = iplot (a,pl)
0011 %
0012 % INPUTS:      pl   - a parameter list
0013 %              a    - input analysis object
0014 %
0015 % OUTPUTS:     hfig - handles to figures
0016 %              hax  - handles to axes
0017 %              hli  - handles to lines
0018 %
0019 % Plot parameters:
0020 %
0021 %             'type' - one of the data class types
0022 %                      'tsdata' [default], 'fsdata', 'cdata', 'xydata', 'xyzdata'.
0023 %
0024 %             'Arrangement' - select the plot layout:
0025 %                           'single'   - plots all AOs on individual figures
0026 %                           'stacked'  - plots all AOs on the same axes [default]
0027 %                           'subplots' - plots all AOs on subplots
0028 %
0029 % Line parameters:
0030 %
0031 %        The following properties take cell array values. If the length of
0032 %        the cell array is shorter than the number of lines to plot, the
0033 %        remaining lines will be plotted with the default options. If the
0034 %        cell array is of length 2 and the first cell contains the string
0035 %        'all', then the second cell is used to set the propery of all
0036 %        lines.
0037 %
0038 %             'LineColors' - a cell array of color definitions for each line.
0039 %
0040 %             'LineStyles' - a cell array of line styles.
0041 %
0042 %             'Markers'    - a cell array of markers.
0043 %
0044 %             'LineWidths' - a cell array of line widths. If the length of the
0045 %                            cell array is shorter than the number of lines to
0046 %                            plot, the remaining lines will be plotted with
0047 %                            the default line width.
0048 %
0049 % Axes parameters:
0050 %
0051 %             'Legends' - specify a cell array of strings to be used for
0052 %                         the plot legends. If a cell contains an empty
0053 %                         string, the default legend string is built.
0054 %                         If a single string 'off' is given instead of a
0055 %                         cell array, then the legends are all switched
0056 %                         off.
0057 %
0058 %             'XLabels' - Specify the labels to be used on the x-axis. The
0059 %                         units are added from the data object 'xunits'
0060 %                         property.
0061 %
0062 %             'YLabels' - Specify the labels to be used on the y-axis. The
0063 %                         units are added from the data object 'yunits'
0064 %                         property. If the object contains complex data,
0065 %                         you should specify two y-labels for that object.
0066 %
0067 %    The following axis properties also work with the 'all' keyword as
0068 %    described above in the line properties section.
0069 %
0070 %             'XScales' - Specify the scales to be used on the x-axes.
0071 %
0072 %             'YScales' - Specify the scales to the used on the y-axes. If
0073 %                         an object contains complex data, you should
0074 %                         specify two y-labels for that object.
0075 %
0076 %             'XRanges' - Specify the ranges to be displayed on the x-axes.
0077 %
0078 %             'YRanges' - Specify the ranges to the displayed on the
0079 %                         y-axes.
0080 %
0081 %
0082 % VERSION:     $Id: iplot.m,v 1.25 2008/02/12 09:29:24 mauro Exp $
0083 %
0084 % EXAMPLES:
0085 %
0086 % 1) Plot two time-series AOs with different colors, line styles, and widths
0087 %
0088 %   pl = plist('Linecolors', {'g', 'k'}, 'LineStyles', {'', '--'}, 'LineWidths', {1, 4});
0089 %   iplot(tsao1, tsao2, pl);
0090 %
0091 % 2) Plot two time-series AOs in subplots. Also overide the second legend
0092 %    text and the first line style.
0093 %
0094 %   pl = plist('Arrangement', 'subplots', 'LineStyles', {'--'}, 'Legends', {'', 'My Sine Wave'});
0095 %   iplot(tsao1, tsao2, pl);
0096 %
0097 % 3) Plot two time-series AOs taking the square of the y-values of the
0098 %    first AO and the log of the x-values of the second AO.
0099 %
0100 %   pl = plist('Arrangement', 'subplots', 'YMaths', 'y.^2', 'XMaths', {'', 'log(x)'});
0101 %   iplot(tsao1, tsao2, pl);
0102 %
0103 % 4) Plot two frequency-series AOs on subplots with the same Y-scales and
0104 %    Y-ranges
0105 %
0106 %   pl1 = plist('Yscales', {'All', 'lin'});
0107 %   pl2 = plist('arrangement', 'subplots', 'YRanges', {'All', [1e-6 100]});
0108 %   iplot(fsd1, fsd2, pl1, pl2)
0109 %
0110 %
0111 % The following call returns a parameter list object that contains the
0112 % default parameter values:
0113 %
0114 % >> pl = iplot(ao, 'Params')
0115 %
0116 % The following call returns a string that contains the routine CVS version:
0117 %
0118 % >> version = iplot(ao,'Version')
0119 %
0120 % The following call returns a string that contains the routine category:
0121 %
0122 % >> category = iplot(ao,'Category')
0123 %
0124 % HISTORY: 22-12-07 M Hewitson
0125 %             Creation
0126 %
0127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0128 
0129 
0130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0131 %
0132 % TODO:
0133 %    1) Add XRange, YRange, ZRange to xyzdata
0134 %    5) How do we deal with axis units? Symbolic math toolbox?
0135 %    7) Should we have a plot_plist field in AO? Then this can be combined
0136 %       with the input plist.
0137 %
0138 
0139 %% Check if this is a call for parameters, version or category
0140 
0141 VERSION = '$Id: iplot.m,v 1.25 2008/02/12 09:29:24 mauro Exp $';
0142 CATEGORY = 'Output';
0143 bs      = [];
0144 
0145 if  (nargin == 2 || nargin == 3) &&...
0146     isa(varargin{1}, 'ao') &&...
0147     ischar(varargin{2})
0148   if strcmp(varargin{2}, 'Params')
0149     if nargin == 2
0150       varargout{1} = getDefaultPlist();
0151     else
0152       varargout{1} = getDefaultPlist(varargin{3});
0153     end
0154     return
0155   elseif strcmp(varargin{2}, 'Version')
0156     varargout{1} = VERSION;
0157     return
0158   elseif strcmp(varargin{2}, 'Category')
0159     varargout{1} = CATEGORY;
0160     return
0161   end
0162 end
0163 
0164 
0165 %% Collect input ao's, plist's and ao variable names
0166 in_names = {};
0167 for ii = 1:nargin
0168   in_names{end+1} = inputname(ii);
0169 end
0170 
0171 [as, upl, invars] = collect_inputs(varargin, in_names);
0172 
0173 %% Go through AOs and collect them into similar types
0174 
0175 tsAOs  = [];
0176 fsAOs  = [];
0177 xyAOs  = [];
0178 xyzAOs = [];
0179 cAOs   = [];
0180 
0181 for j=1:numel(as)
0182   switch class(as(j).data)
0183     case 'tsdata'
0184       tsAOs = [tsAOs as(j)];
0185     case 'fsdata'
0186       fsAOs = [fsAOs as(j)];
0187     case 'xydata'
0188       xyAOs = [xyAOs as(j)];
0189     case 'xyzdata'
0190       xyzAOs = [xyzAOs as(j)];
0191     case 'cdata'
0192       cAOs = [cAOs as(j)];
0193     otherwise
0194       warning('!!! Unknown data type %s', class(as(j).data));
0195   end
0196 end
0197 
0198 %% Now plot all the objects on separate figures
0199 
0200 hfig = [];
0201 hax  = [];
0202 hli  = [];
0203 
0204 %----------- TSDATA
0205 
0206 % get default plist
0207 dpl = getDefaultPlist('tsdata');
0208 % combine the plists
0209 pl = combine(upl, dpl);
0210 % Call x-y plot
0211 [hf, ha, hl] = xy_plot(tsAOs, pl);
0212 hfig = [hfig hf];
0213 hax  = [hax ha];
0214 hli  = [hli hl];
0215 
0216 %----------- XYDATA
0217 
0218 % get default plist
0219 dpl = getDefaultPlist('xydata');
0220 % combine the plists
0221 pl = combine(upl, dpl);
0222 % Call x-y plot
0223 [hf, ha, hl] = xy_plot(xyAOs, pl);
0224 hfig = [hfig hf];
0225 hax  = [hax ha];
0226 hli  = [hli hl];
0227 
0228 %----------- XYZDATA
0229 
0230 % get default plist
0231 dpl = getDefaultPlist('xyzdata');
0232 % combine the plists
0233 pl = combine(upl, dpl);
0234 % Call x-y-z plot
0235 [hf, ha, hl] = xyz_plot(xyzAOs, pl);
0236 hfig = [hfig hf];
0237 hax  = [hax ha];
0238 hli  = [hli hl];
0239 
0240 %----------- CDATA
0241 
0242 % get default plist
0243 dpl = getDefaultPlist('cdata');
0244 % combine the plists
0245 pl = combine(upl, dpl);
0246 % Call x-y plot
0247 [hf, ha, hl] = y_plot(cAOs, pl);
0248 hfig = [hfig hf];
0249 hax  = [hax ha];
0250 hli  = [hli hl];
0251 
0252 %----------- FSDATA
0253 
0254 % get default plist
0255 dpl = getDefaultPlist('fsdata');
0256 % combine the plists
0257 pl = combine(upl, dpl);
0258 % Call fsdata plot
0259 [hf, ha, hl] = fs_plot(fsAOs, pl);
0260 hfig = [hfig hf];
0261 hax  = [hax ha];
0262 hli  = [hli hl];
0263 
0264 %% Deal with outputs
0265 if nargout == 1
0266   varargout{1} = hfig;
0267 end
0268 if nargout == 2
0269   varargout{1} = hfig;
0270   varargout{2} = hax;
0271 end
0272 if nargout == 3
0273   varargout{1} = hfig;
0274   varargout{2} = hax;
0275   varargout{3} = hli;
0276 end
0277 
0278 if nargout > 3
0279   error('### Incorrect number of outputs');
0280 end
0281 
0282 
0283 %--------------------------------------------------------------------------
0284 % Plot fsdata objects
0285 %
0286 function varargout = fs_plot(varargin)
0287 
0288 aos = varargin{1};
0289 pl  = varargin{2};
0290 
0291 % Extract parameters
0292 arrangement = find(pl, 'Arrangement');
0293 colors      = find(pl, 'Colors');
0294 
0295 linecolors  = find(pl, 'LineColors');
0296 linestyles  = find(pl, 'LineStyles');
0297 markers     = find(pl, 'Markers');
0298 linewidths  = find(pl, 'LineWidths');
0299 legends     = find(pl, 'Legends');
0300 ylabels     = find(pl, 'YLabels');
0301 xlabels     = find(pl, 'XLabels');
0302 yscales     = find(pl, 'YScales');
0303 xscales     = find(pl, 'XScales');
0304 yranges     = find(pl, 'YRanges');
0305 xranges     = find(pl, 'XRanges');
0306 xmaths      = find(pl, 'XMaths');
0307 ymaths      = find(pl, 'YMaths');
0308 
0309 complexPlotType = find(pl, 'complexPlotType');
0310 
0311 % check whether we want legends or not
0312 if iscell(legends)
0313   legendsOn = 1;
0314 else
0315   if strcmpi(legends, 'off')
0316     legendsOn = 0;
0317   else
0318     legendsOn = 1;
0319     legends = [];
0320   end
0321 end
0322 
0323 if ~iscell(linewidths), linewidths = {linewidths}; end
0324 if ~iscell(linestyles), linestyles = {linestyles}; end
0325 if ~iscell(linecolors), linecolors = {linecolors}; end
0326 if ~iscell(markers), markers = {markers}; end
0327 if ~iscell(legends), legends = {legends}; end
0328 if ~iscell(ylabels), ylabels = {ylabels}; end
0329 if ~iscell(xlabels), xlabels = {xlabels}; end
0330 if ~iscell(xmaths), xmaths = {xmaths}; end
0331 if ~iscell(ymaths), ymaths = {ymaths}; end
0332 if ~iscell(xscales), xscales = {xscales}; end
0333 if ~iscell(yscales), yscales = {yscales}; end
0334 if ~iscell(xranges), xranges = {xranges}; end
0335 if ~iscell(yranges), yranges = {yranges}; end
0336 
0337 
0338 % collect figure handles
0339 tsfig = [];
0340 tsax  = [];
0341 tsli  = [];
0342 
0343 % Legend holder
0344 legendStr = [];
0345 
0346 if ~isempty(aos)
0347 
0348   % Now loop over AOs
0349   Na = length(aos);
0350   
0351   % - first to check if any are complex
0352   haveComplex = 0;
0353   for j=1:Na
0354     a = aos(j);
0355     y = a.data.y;
0356     ymath = '';
0357     if j<=length(ymaths)
0358       if ~isempty(ymaths{j})
0359         eval(sprintf('y = %s;', ymaths{j}));
0360         ymath = ymaths{j};
0361       end
0362     end
0363     xmath = '';
0364     if j<=length(xmaths)
0365       if ~isempty(xmaths{j})
0366         eval(sprintf('x = %s;', xmaths{j}));
0367         xmath = xmaths{j};
0368       end
0369     end
0370     if ~isreal(y)
0371       haveComplex = 1;
0372     end    
0373   end
0374   
0375   % Loop over the AOs now
0376   for j=1:Na
0377     
0378     % set real and imag subplot handles to empty
0379     tsax_r = [];
0380     tsax_i = [];
0381     
0382     % Get this AO
0383     a = aos(j);
0384     
0385     %------- Apply math functions
0386     x = a.data.x;
0387     y = a.data.y;
0388     
0389     ymath = '';
0390     if j<=length(ymaths)
0391       if ~isempty(ymaths{j})
0392         eval(sprintf('y = %s;', ymaths{j}));
0393         ymath = ymaths{j};
0394       end
0395     end
0396     xmath = '';
0397     if j<=length(xmaths)
0398       if ~isempty(xmaths{j})
0399         eval(sprintf('x = %s;', xmaths{j}));
0400         xmath = xmaths{j};
0401       end
0402     end
0403     
0404     % what figures do we need?
0405     switch arrangement
0406       case 'single'        
0407         
0408         tsfig = [tsfig figure];
0409         col = colors{1};
0410         % check if this data set is real or complex
0411         if ~isreal(y)
0412           % complex means we use two subplots
0413           tsax_r = subplot(2,1,1);
0414           tsax_i = subplot(2,1,2);
0415           tsax   = [tsax tsax_r tsax_i];
0416         else
0417           % real means we use a single subplot
0418           tsax_r = subplot(1, 1, 1);
0419           tsax = [tsax tsax_r];
0420         end
0421         
0422       case 'stacked'
0423         
0424         if j==1, tsfig = figure; end
0425         % if at least one of the input fsdata AOs is complex, we need to
0426         % allow for subplots
0427         if haveComplex
0428           tsax_r = subplot(2,1,1);
0429           tsax_i = subplot(2,1,2);
0430           tsax   = [tsax_r tsax_i];
0431         else
0432           tsax_r = subplot(1, 1, 1);
0433           tsax = tsax_r;
0434         end
0435         col = colors{mod(j-1,length(colors))+1};
0436         hold(tsax_r, 'on');
0437         if ishandle(tsax_i)
0438           hold(tsax_i, 'on');
0439         end      
0440       case 'subplots'
0441         
0442         if j == 1, tsfig = figure; end
0443         c = 1+(j-1)*2;
0444         sx = Na;
0445         sy = 2;
0446         % Now we have one or two subplots per input object.
0447         if ~isreal(y)
0448           tsax_r = subplot(sx, sy,c);
0449           tsax_i = subplot(sx, sy,c+1);
0450           tsax   = [tsax tsax_r tsax_i];
0451         else
0452           tsax_r = subplot(sx, sy, c:c+1);
0453           tsax   = [tsax tsax_r];
0454         end
0455         col = colors{1};
0456         
0457       otherwise
0458         error('### Unknown plot arrangement');
0459     end
0460 
0461     %------- Plot the data
0462     
0463     % plot real or complex data and setup default values for scale and
0464     % labels as we go.
0465     if isreal(y)
0466       li   = plot(tsax_r, x, y);
0467       tsli = [tsli li];
0468       ylabelr = 'amplitude';
0469       ylabeli = 'imag';
0470       yscaleR = 'log';
0471       yscaleI = 'lin';
0472       xscaleR = 'log';
0473       xscaleI = 'lin';
0474     else
0475       switch complexPlotType
0476         case 'realimag'
0477           li = plot(tsax_r, x, y);
0478           li = [li plot(tsax_i, x, imag(y))];
0479           tsli = [tsli li];
0480           ylabelr = 'real';
0481           ylabeli = 'imag';
0482           yscaleR = 'lin';
0483           yscaleI = 'lin';
0484           xscaleR = 'lin';
0485           xscaleI = 'lin';
0486         case 'absdeg'
0487           li   = plot(tsax_r, x, abs(y));
0488           li   = [li plot(tsax_i, x, ltpda_phase(y))];
0489           tsli = [tsli li];
0490           ylabelr = 'amplitude';
0491           ylabeli = 'Phase [deg]';
0492           yscaleR = 'log';
0493           yscaleI = 'lin';
0494           xscaleR = 'log';
0495           xscaleI = 'log';
0496         case 'absrad'
0497           li   = plot(tsax_r, x, abs(y));
0498           li   = [li plot(tsax_i, x, angle(y))];
0499           tsli = [tsli li];
0500           ylabelr = 'amplitude';
0501           ylabeli = 'phase [rad]';
0502           yscaleR = 'log';
0503           yscaleI = 'lin';
0504           xscaleR = 'log';
0505           xscaleI = 'log';
0506         otherwise
0507           error('### Unknown plot type for complex data');
0508       end
0509     end
0510     
0511     %------- Axis properties
0512         
0513     % Set ylabel
0514     c = 1+(j-1)*2;
0515     if c<=length(ylabels)
0516       if ~isempty(ylabels{c})
0517         ylstrR =  ylabels{c};
0518       else
0519         ylstrR = ylabelr; 
0520       end
0521     else
0522       ylstrR = ylabelr;
0523     end
0524     if c<length(ylabels)
0525       if ~isempty(ylabels{c+1})
0526         ylstrI =  ylabels{c+1};
0527       else
0528         ylstrI = ylabeli;
0529       end
0530     else
0531       ylstrI = ylabeli;
0532     end    
0533     if ~isempty(ymath)
0534       ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
0535       ylstrR = [ylstrR ' [' ymath ']' ];
0536     else
0537       ylstrR = [ylstrR ' [' a.data.yunits ']' ];
0538     end
0539     ylabel(tsax_r, ylstrR);
0540     if ishandle(tsax_i)
0541       ylabel(tsax_i, ylstrI);
0542     end
0543     
0544     % Set xlabel
0545     if j<=length(xlabels) && ~isempty(xlabels{j})
0546         xlstr =  xlabels{j};
0547     else
0548       xlstr = find(pl, 'XLabel');
0549     end    
0550     if ~isempty(xmath)
0551       xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
0552       xlstr = [xlstr ' [' xmath ']' ];
0553     else
0554       xlstr = [xlstr ' [' a.data.xunits ']' ];
0555     end
0556     xlabel(tsax_r, xlstr);
0557     if ishandle(tsax_i)
0558       xlabel(tsax_i, xlstr);
0559     end    
0560 
0561     % Set grid on or off
0562     grid(tsax_r, 'on');
0563     if ishandle(tsax_i)
0564       grid(tsax_i, 'on');
0565     end
0566     
0567     % Set Y scale
0568     if length(yscales)==2 && strcmpi(yscales{1}, 'all')
0569       yscaleR = yscales{2};
0570       yscaleI = yscales{2};
0571     else
0572       c = 1+(j-1)*2;
0573       if c<=length(yscales)
0574         if ~isempty(yscales{c})
0575           yscaleR =  yscales{c};
0576         end
0577       end
0578       if c<length(yscales)
0579         if ~isempty(yscales{c+1})
0580           yscaleI =  yscales{c+1};
0581         end
0582       end
0583     end
0584     
0585     set(tsax_r, 'YScale', yscaleR);
0586     if ishandle(tsax_i)
0587       set(tsax_i, 'YScale', yscaleI);
0588     end
0589     
0590     % Set X scale
0591     if length(xscales)==2 && strcmpi(xscales{1}, 'all')
0592       xscaleR = xscales{2};
0593       xscaleI = xscales{2};
0594     else
0595       c = 1+(j-1)*2;
0596       if c<=length(xscales)
0597         if ~isempty(xscales{c})
0598           xscaleR =  xscales{c};
0599         end
0600       end
0601       if c<length(xscales)
0602         if ~isempty(xscales{c+1})
0603           xscaleI =  xscales{c+1};
0604         end
0605       end
0606     end
0607     set(tsax_r, 'XScale', xscaleR);
0608     if ishandle(tsax_i)
0609       set(tsax_i, 'XScale', xscaleI);
0610     end
0611     
0612     % Set Y range
0613     if length(yranges)==2 && strcmpi(yranges{1}, 'all')
0614       set(tsax_r, 'YLim', yranges{2});
0615       if ishandle(tsax_i)
0616         set(tsax_i, 'YLim', yranges{2});
0617       end
0618     else
0619       c = 1+(j-1)*2;
0620       if c<=length(yranges)
0621         if ~isempty(yranges{c})
0622           set(tsax_r, 'YLim', yranges{c});
0623         end
0624       end
0625       if c<length(yranges)
0626         if ~isempty(yranges{c+1})
0627           if ishandle(tsax_i)
0628             set(tsax_i, 'YLim', yranges{c+1});
0629           end
0630         end
0631       end
0632     end
0633     
0634     % Set X range
0635     if length(xranges)==2 && strcmpi(xranges{1}, 'all')
0636       set(tsax_r, 'XLim', xranges{2});
0637       if ishandle(tsax_i)
0638         set(tsax_i, 'XLim', xranges{2});
0639       end
0640     else
0641       c = 1+(j-1)*2;
0642       if c<=length(xranges)
0643         if ~isempty(xranges{c})
0644           set(tsax_r, 'XLim', xranges{c});
0645         end
0646       end
0647       if c<length(xranges)
0648         if ~isempty(xranges{c+1})
0649           if ishandle(tsax_i)
0650             set(tsax_i, 'XLim', xranges{c+1});
0651           end
0652         end
0653       end
0654     end
0655     
0656     %------- line properties
0657     
0658     % Set line color
0659     if isreal(y)
0660       set(li, 'Color', col);
0661     else
0662       set(li, 'Color', col);
0663       set(li, 'Color', col);
0664     end
0665     
0666     % Overide with user colors
0667     if length(linecolors) == 2 && strcmpi(linecolors{1}, 'all')
0668       set(li, 'Color', linecolors{2});
0669     else
0670       if j<=length(linecolors) && ~isempty(linecolors{j})
0671         if isreal(y)
0672           set(li, 'Color', linecolors{j});
0673         else
0674           set(li, 'Color', linecolors{j});
0675           set(li, 'Color', linecolors{j});
0676         end
0677       end
0678     end
0679     
0680     % Set line style
0681     if length(linestyles) == 2 && strcmpi(linestyles{1}, 'all')
0682       set(li, 'LineStyle', linestyles{2});
0683     else
0684       if j<=length(linestyles) && ~isempty(linestyles{j})
0685         if isreal(y)
0686           set(li, 'LineStyle', linestyles{j});
0687         else
0688           set(li, 'LineStyle', linestyles{j});
0689           set(li, 'LineStyle', linestyles{j});
0690         end
0691       end
0692     end
0693     
0694     % Set line widths
0695     if length(linewidths) == 2 && strcmpi(linewidths{1}, 'all')
0696       set(li, 'LineWidth', linewidths{2});
0697     else
0698       if j<=length(linewidths) && ~isempty(linewidths{j})
0699         if isreal(y)
0700           set(li, 'LineWidth', linewidths{j});
0701         else
0702           set(li, 'LineWidth', linewidths{j});
0703           set(li, 'LineWidth', linewidths{j});
0704         end
0705       end
0706     end
0707 
0708     % Set markers
0709     if length(markers) == 2 && strcmpi(markers{1}, 'all')
0710       set(li, 'Marker', markers{2});
0711     else
0712       if j<=length(markers) && ~isempty(markers{j})
0713         if isreal(y)
0714           set(li, 'Marker', markers{j});
0715         else
0716           set(li, 'Marker', markers{j});
0717           set(li, 'Marker', markers{j});
0718         end
0719       end
0720     end
0721     
0722     
0723     % Set legend string
0724     lstr = '';
0725     if legendsOn
0726       if j<=length(legends) && ~isempty(legends{j})
0727         lstr = legends{j};
0728       else
0729         lstr = ltpda_label(a.name);
0730       end
0731     end
0732     legendStr = [legendStr cellstr(lstr)];
0733 
0734     % Set the legend now if we can
0735     if legendsOn
0736       if strcmp(arrangement, 'single') || strcmp(arrangement, 'subplots')
0737         legend(tsax_r, legendStr{end});
0738       end
0739     end
0740 
0741   end % End loop over AOs
0742   
0743   % Process legends for stacked plots
0744   if legendsOn
0745     if strcmp(arrangement, 'stacked')
0746       h = legend(tsax_r, legendStr);
0747       set(h, 'FontSize', 10)
0748     end
0749   end
0750   
0751 end
0752 
0753 % Set outputs
0754 if nargout > 0
0755   varargout{1} = tsfig;
0756 end
0757 if nargout > 1
0758   varargout{2} = tsax;
0759 end
0760 if nargout == 3
0761   varargout{3} = tsli;
0762 end
0763 if nargout > 3
0764   error('### Too many output arguments');
0765 end
0766 
0767 %--------------------------------------------------------------------------
0768 % Plot tsdata and xydata objects
0769 %
0770 function varargout = xy_plot(varargin)
0771 
0772 aos = varargin{1};
0773 pl  = varargin{2};
0774 
0775 % Extract parameters
0776 arrangement = find(pl, 'Arrangement');
0777 linecolors  = find(pl, 'LineColors');
0778 colors      = find(pl, 'Colors');
0779 linestyles  = find(pl, 'LineStyles');
0780 markers     = find(pl, 'Markers');
0781 linewidths  = find(pl, 'LineWidths');
0782 legends     = find(pl, 'Legends');
0783 ylabels     = find(pl, 'YLabels');
0784 xlabels     = find(pl, 'XLabels');
0785 xmaths      = find(pl, 'XMaths');
0786 ymaths      = find(pl, 'YMaths');
0787 yranges     = find(pl, 'YRanges');
0788 xranges     = find(pl, 'XRanges');
0789 yscales     = find(pl, 'YScales');
0790 xscales     = find(pl, 'XScales');
0791 
0792 % check whether we want legends or not
0793 if iscell(legends)
0794   legendsOn = 1;
0795 else
0796   if strcmpi(legends, 'off')
0797     legendsOn = 0;
0798   else
0799     legendsOn = 1;
0800     legends = [];
0801   end
0802 end
0803 
0804 if ~iscell(linewidths), linewidths = {linewidths}; end
0805 if ~iscell(linestyles), linestyles = {linestyles}; end
0806 if ~iscell(linecolors), linecolors = {linecolors}; end
0807 if ~iscell(markers), markers = {markers}; end
0808 if ~iscell(legends), legends = {legends}; end
0809 if ~iscell(ylabels), ylabels = {ylabels}; end
0810 if ~iscell(xlabels), xlabels = {xlabels}; end
0811 if ~iscell(xmaths), xmaths = {xmaths}; end
0812 if ~iscell(ymaths), ymaths = {ymaths}; end
0813 if ~iscell(xranges), xranges = {xranges}; end
0814 if ~iscell(yranges), yranges = {yranges}; end
0815 if ~iscell(xscales), xscales = {xscales}; end
0816 if ~iscell(yscales), yscales = {yscales}; end
0817 
0818 % collect figure handles
0819 tsfig = [];
0820 tsax  = [];
0821 tsli  = [];
0822 
0823 % Legend holder
0824 legendStr = [];
0825 
0826 if ~isempty(aos)
0827 
0828   % Now loop over AOs to get earliest start time
0829   if strcmp(arrangement, 'stacked')
0830     T0 = 1e50;
0831     Na = length(aos);
0832     for j=1:Na
0833       % Get this AO
0834       a = aos(j);
0835       if isa(a.data, 'tsdata')
0836         if a.data.t0.utc_epoch_milli/1000 < T0
0837           T0 = floor(a.data.t0.utc_epoch_milli/1000);
0838         end
0839       end
0840     end
0841   else
0842     T0 = 0;
0843   end
0844   
0845   
0846   % Now loop over AOs
0847   Na = length(aos);
0848   for j=1:Na
0849     
0850     % Get this AO
0851     a = aos(j);
0852     toff = 0;
0853     
0854     % what figures do we need?
0855     switch arrangement
0856       case 'single'        
0857         
0858         tsfig = [tsfig figure];
0859         tsax = subplot(1,1,1);
0860         col = colors{1};
0861         if isa(a.data, 'tsdata')
0862           torigin = a.data.t0;
0863         end
0864       case 'stacked'
0865         
0866         if j==1, tsfig = figure; end
0867         tsax = subplot(1,1,1);
0868         col = colors{mod(j-1,length(colors))+1};
0869         hold on;
0870         % deal with time-stamps here
0871         if isa(a.data, 'tsdata')
0872           toff = a.data.t0.utc_epoch_milli/1000 - T0;
0873         else
0874           toff = 0;
0875         end
0876         if isa(a.data, 'tsdata')
0877           torigin = time(T0*1000);
0878         end        
0879       case 'subplots'
0880         
0881         if j == 1, tsfig = figure; end
0882         tsax = [tsax subplot(Na, 1, j)];
0883         col = colors{1};
0884         if isa(a.data, 'tsdata')
0885           torigin = a.data.t0;
0886         end
0887       otherwise
0888         error('### Unknown plot arrangement');
0889     end
0890 
0891     %------- Apply math functions
0892     
0893     % need t0 offset for this time-series
0894     x = a.data.x + toff;
0895     y = a.data.y;
0896     
0897     ymath = '';
0898     if j<=length(ymaths)
0899       if ~isempty(ymaths{j})
0900         eval(sprintf('y = %s;', ymaths{j}));
0901         ymath = ymaths{j};
0902       end
0903     end
0904     xmath = '';
0905     if j<=length(xmaths)
0906       if ~isempty(xmaths{j})
0907         eval(sprintf('x = %s;', xmaths{j}));
0908         xmath = xmaths{j};
0909       end
0910     end
0911     
0912     %------- Plot the data
0913     
0914     li   = plot(tsax(end), x, y);
0915     tsli = [tsli li];
0916     if isa(a.data, 'tsdata')
0917       title(sprintf('Time origin: %s', torigin.time_str));
0918     end  
0919     %------- Axis properties
0920         
0921     % Set ylabel
0922     if j<=length(ylabels) && ~isempty(ylabels{j})
0923         ylstr =  ylabels{j};
0924     else
0925       ylstr = find(pl, 'YLabel');
0926     end    
0927     if ~isempty(ymath)
0928       ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
0929       ylstr = [ylstr ' [' ymath ']' ];
0930     else
0931       ylstr = [ylstr ' [' a.data.yunits ']' ];
0932     end
0933     ylabel(ylstr);
0934     
0935     % Set xlabel
0936     if j<=length(xlabels) && ~isempty(xlabels{j})
0937         xlstr =  xlabels{j};
0938     else
0939       xlstr = find(pl, 'XLabel');
0940     end    
0941     if ~isempty(xmath)
0942       xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
0943       xlstr = [xlstr ' [' xmath ']' ];
0944     else
0945       xlstr = [xlstr ' [' a.data.xunits ']' ];
0946     end
0947     xlabel(xlstr);
0948     
0949     % Set Y range
0950     if length(yranges) == 2 && strcmpi(yranges{1}, 'all')
0951       set(tsax(end), 'YLim', yranges{2});
0952     else
0953       if j<=length(yranges)
0954         if ~isempty(yranges{j})
0955           set(tsax(end), 'YLim', yranges{j});
0956         end
0957       end
0958     end
0959     
0960     % Set Y scale
0961     yscaleR = 'lin';
0962     if length(yscales)==2 && strcmpi(yscales{1}, 'all')
0963       yscaleR = yscales{2};
0964     else
0965       if j<=length(yscales)
0966         if ~isempty(yscales{j})
0967           yscaleR =  yscales{j};
0968         end
0969       end
0970     end    
0971     set(tsax(end), 'YScale', yscaleR);
0972     
0973     % Set X scale
0974     xscaleR = 'lin';
0975     if length(xscales)==2 && strcmpi(xscales{1}, 'all')
0976       xscaleR = xscales{2};
0977     else
0978       if j<=length(xscales)
0979         if ~isempty(xscales{j})
0980           xscaleR =  xscales{j};
0981         end
0982       end
0983     end
0984     set(tsax(end), 'XScale', xscaleR);
0985     
0986     % Set X range
0987     if length(xranges) == 2 && strcmpi(xranges{1}, 'all')
0988       set(tsax(end), 'XLim', xranges{2});
0989     else
0990       if j<=length(xranges)
0991         if ~isempty(xranges{j})
0992           set(tsax(end), 'XLim', xranges{j});
0993         end
0994       end
0995     end
0996     
0997     % Set grid on or off
0998     grid(tsax(end), 'on');
0999     
1000     %------- line properties
1001     
1002     % Set line color
1003     set(li, 'Color', col);
1004     
1005     % Set specific colors
1006     if length(linecolors) == 2 && strcmpi(linecolors{1}, 'all')
1007       set(li, 'Color', linecolors{2});
1008     else
1009       if j<=length(linecolors) && ~isempty(linecolors{j})
1010         set(li, 'Color', linecolors{j});
1011       end
1012     end
1013     
1014     % Set line style
1015     if length(linestyles) == 2 && strcmpi(linestyles{1}, 'all')
1016       set(li, 'LineStyle', linestyles{2});
1017     else
1018       if j<=length(linestyles) && ~isempty(linestyles{j})
1019         set(li, 'LineStyle', linestyles{j});
1020       end
1021     end
1022     
1023     % Set markers
1024     if length(markers) == 2 && strcmpi(markers{1}, 'all')
1025       set(li, 'Marker', markers{2});
1026     else
1027       if j<=length(markers) && ~isempty(markers{j})
1028         set(li, 'Marker', markers{j});
1029       end
1030     end
1031     
1032     % Set line widths
1033     if length(linewidths) == 2 && strcmpi(linewidths{1}, 'all')
1034       set(li, 'LineWidth', linewidths{2});
1035     else
1036       if j<=length(linewidths) && ~isempty(linewidths{j})
1037         set(li, 'LineWidth', linewidths{j});
1038       end
1039     end
1040     
1041     % Set legend string
1042     lstr = '';
1043     if legendsOn
1044       if j<=length(legends) && ~isempty(legends{j})
1045         lstr = legends{j};
1046       else
1047         lstr = ltpda_label(a.name);
1048       end
1049     end
1050     legendStr = [legendStr cellstr(lstr)];
1051     
1052     % Set the legend now if we can
1053     if legendsOn
1054       if strcmp(arrangement, 'single') || strcmp(arrangement, 'subplots')
1055         legend(legendStr{end});
1056       end
1057     end
1058   end
1059   
1060   % Process legends for stacked plots
1061   if legendsOn
1062     if strcmp(arrangement, 'stacked')
1063       h = legend(legendStr);
1064       set(h, 'FontSize', 10)
1065     end
1066   end
1067   
1068 end
1069 
1070 % Set outputs
1071 if nargout > 0
1072   varargout{1} = tsfig;
1073 end
1074 if nargout > 1
1075   varargout{2} = tsax;
1076 end
1077 if nargout == 3
1078   varargout{3} = tsli;
1079 end
1080 if nargout > 3
1081   error('### Too many output arguments');
1082 end
1083 
1084 
1085 %--------------------------------------------------------------------------
1086 % Plot cdata objects
1087 %
1088 function varargout = y_plot(varargin)
1089 
1090 aos = varargin{1};
1091 pl  = varargin{2};
1092 
1093 % Extract parameters
1094 arrangement = find(pl, 'Arrangement');
1095 linecolors  = find(pl, 'LineColors');
1096 colors      = find(pl, 'Colors');
1097 linestyles  = find(pl, 'LineStyles');
1098 markers     = find(pl, 'Markers');
1099 linewidths  = find(pl, 'LineWidths');
1100 legends     = find(pl, 'Legends');
1101 ylabels     = find(pl, 'YLabels');
1102 xlabels     = find(pl, 'XLabels');
1103 xmaths      = find(pl, 'XMaths');
1104 ymaths      = find(pl, 'YMaths');
1105 yranges     = find(pl, 'YRanges');
1106 xranges     = find(pl, 'XRanges');
1107 yscales     = find(pl, 'YScales');
1108 xscales     = find(pl, 'XScales');
1109 if ~iscell(xscales), xscales = {xscales}; end
1110 if ~iscell(yscales), yscales = {yscales}; end
1111 
1112 % check whether we want legends or not
1113 if iscell(legends)
1114   legendsOn = 1;
1115 else
1116   if strcmp(legends, 'off')
1117     legendsOn = 0;
1118   else
1119     legendsOn = 1;
1120     legends = [];
1121   end
1122 end
1123 
1124 if ~iscell(linewidths), linewidths = {linewidths}; end
1125 if ~iscell(linestyles), linestyles = {linestyles}; end
1126 if ~iscell(linecolors), linecolors = {linecolors}; end
1127 if ~iscell(markers), markers = {markers}; end
1128 if ~iscell(legends), legends = {legends}; end
1129 if ~iscell(ylabels), ylabels = {ylabels}; end
1130 if ~iscell(xlabels), xlabels = {xlabels}; end
1131 if ~iscell(xmaths), xmaths = {xmaths}; end
1132 if ~iscell(ymaths), ymaths = {ymaths}; end
1133 if ~iscell(xranges), xranges = {xranges}; end
1134 if ~iscell(yranges), yranges = {yranges}; end
1135 
1136 % collect figure handles
1137 tsfig = [];
1138 tsax  = [];
1139 tsli  = [];
1140 
1141 % Legend holder
1142 legendStr = [];
1143 
1144 if ~isempty(aos)
1145 
1146   % Now loop over AOs
1147   Na = length(aos);
1148   for j=1:Na
1149     
1150     % Get this AO
1151     a = aos(j);
1152     
1153     % what figures do we need?
1154     switch arrangement
1155       case 'single'        
1156         
1157         tsfig = [tsfig figure];
1158         tsax = subplot(1,1,1);
1159         col = colors{1};
1160         
1161       case 'stacked'
1162         
1163         if j==1, tsfig = figure; end
1164         tsax = subplot(1,1,1);
1165         col = colors{mod(j-1,length(colors))+1};
1166         hold on;
1167         
1168       case 'subplots'
1169         
1170         if j == 1, tsfig = figure; end
1171         tsax = [tsax subplot(Na, 1, j)];
1172         col = colors{1};
1173         
1174       otherwise
1175         error('### Unknown plot arrangement');
1176     end
1177 
1178     %------- Apply math functions
1179     if isreal(a.data.y)
1180       x = 1:length(a.data.y);
1181       y = a.data.y;
1182     else
1183       x = real(a.data.y);
1184       y = imag(a.data.y);
1185     end
1186     
1187     ymath = '';
1188     if j<=length(ymaths)
1189       if ~isempty(ymaths{j})
1190         eval(sprintf('y = %s;', ymaths{j}));
1191         ymath = ymaths{j};
1192       end
1193     end
1194     xmath = '';
1195     if j<=length(xmaths)
1196       if ~isempty(xmaths{j})
1197         eval(sprintf('x = %s;', xmaths{j}));
1198         xmath = xmaths{j};
1199       end
1200     end
1201     
1202     %------- Plot the data
1203     
1204     idcs = plot(tsax(end), x, y);
1205     tsli = [tsli idcs(1:end).'];
1206     
1207     %------- Axis properties
1208         
1209     % Set ylabel
1210     if j<=length(ylabels) && ~isempty(ylabels{j})
1211         ylstr =  ylabels{j};
1212     else
1213       ylstr = find(pl, 'YLabel');
1214     end    
1215     if ~isempty(ymath)
1216       ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
1217       ylstr = [ylstr ' [' ymath ']' ];
1218     else
1219       ylstr = [ylstr ' [' a.data.yunits ']' ];
1220     end
1221     ylabel(ylstr);
1222     
1223     % Set xlabel
1224     if j<=length(xlabels) && ~isempty(xlabels{j})
1225         xlstr =  xlabels{j};
1226     else
1227       xlstr = find(pl, 'XLabel');
1228     end    
1229     if ~isempty(xmath)
1230       xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
1231       xlstr = [xlstr ' [' xmath ']' ];
1232     else
1233       xlstr = [xlstr ' [' a.data.xunits ']' ];
1234     end
1235     xlabel(xlstr);
1236     
1237     % Set Y scale
1238     yscaleR = 'lin';
1239     if length(yscales)==2 && strcmpi(yscales{1}, 'all')
1240       yscaleR = yscales{2};
1241     else
1242       if j<=length(yscales)
1243         if ~isempty(yscales{j})
1244           yscaleR =  yscales{j};
1245         end
1246       end
1247     end    
1248     set(tsax(end), 'YScale', yscaleR);
1249     
1250     % Set X scale
1251     xscaleR = 'lin';
1252     if length(xscales)==2 && strcmpi(xscales{1}, 'all')
1253       xscaleR = xscales{2};
1254     else
1255       if j<=length(xscales)
1256         if ~isempty(xscales{j})
1257           xscaleR =  xscales{j};
1258         end
1259       end
1260     end
1261     set(tsax(end), 'XScale', xscaleR);
1262     
1263     % Set Y range
1264     if length(yranges) == 2 && strcmpi(yranges{1}, 'all')
1265       set(tsax(end), 'YLim', yranges{2});
1266     else
1267       if j<=length(yranges)
1268         if ~isempty(yranges{j})
1269           set(tsax(end), 'YLim', yranges{j});
1270         end
1271       end
1272     end
1273     
1274     % Set X range
1275     if length(xranges) == 2 && strcmpi(xranges{1}, 'all')
1276       set(tsax(end), 'XLim', xranges{2});
1277     else
1278       if j<=length(xranges)
1279         if ~isempty(xranges{j})
1280           set(tsax(end), 'XLim', xranges{j});
1281         end
1282       end
1283     end
1284     
1285     % Set grid on or off
1286     grid(tsax(end), 'on');
1287     
1288     %------- line properties
1289     
1290     % Set line color
1291     set(idcs, 'Color', col);
1292     
1293     % Overide line colors with user defined colors
1294     if length(linecolors) == 2 && strcmpi(linecolors{1}, 'all')
1295       set(idcs, 'Color', linecolors{2});
1296     else
1297       if j<=length(linecolors) && ~isempty(linecolors{j})
1298         set(idcs, 'Color', linecolors{j});
1299       end
1300     end
1301     
1302     % Set line style
1303     if length(linestyles) == 2 && strcmpi(linestyles{1}, 'all')
1304       set(idcs, 'LineStyle', linestyles{2});
1305     else
1306       if j<=length(linestyles) && ~isempty(linestyles{j})
1307         set(idcs, 'LineStyle', linestyles{j});
1308       end
1309     end
1310     
1311     % Set Markers
1312     if length(markers) == 2 && strcmpi(markers{1}, 'all')
1313       set(idcs, 'Marker', markers{2});
1314     else
1315       if j<=length(markers) && ~isempty(markers{j})
1316         set(idcs, 'Marker', markers{j});
1317       end
1318     end
1319     
1320     % Set line widths
1321     if length(linewidths) == 2 && strcmpi(linewidths{1}, 'all')
1322       set(idcs, 'LineWidth', linewidths{2});
1323     else
1324       if j<=length(linewidths) && ~isempty(linewidths{j})
1325         set(idcs, 'LineWidth', linewidths{j});
1326       end
1327     end
1328     
1329     % Set legend string
1330     if legendsOn
1331       if j<=length(legends) && ~isempty(legends{j})
1332         legendStr = [legendStr legends(j)];
1333       else
1334         lstr = ltpda_label(a.name);
1335         legendStr = [legendStr cellstr(lstr)];
1336       end
1337     end
1338     
1339     % Set the legend now if we can
1340     if legendsOn
1341       if strcmp(arrangement, 'single') || strcmp(arrangement, 'subplots')
1342         legend(legendStr{end});
1343       end
1344     end
1345   end
1346   
1347   % Process legends for stacked plots
1348   if legendsOn
1349     if strcmp(arrangement, 'stacked')
1350       h = legend(legendStr);
1351       set(h, 'FontSize', 10)
1352     end
1353   end
1354   
1355 end
1356 
1357 % Set outputs
1358 if nargout > 0
1359   varargout{1} = tsfig;
1360 end
1361 if nargout > 1
1362   varargout{2} = tsax;
1363 end
1364 if nargout == 3
1365   varargout{3} = tsli;
1366 end
1367 if nargout > 3
1368   error('### Too many output arguments');
1369 end
1370 
1371 %--------------------------------------------------------------------------
1372 % Plot xyzdata objects
1373 %
1374 function varargout = xyz_plot(varargin)
1375 
1376 aos = varargin{1};
1377 pl  = varargin{2};
1378 
1379 % Extract parameters
1380 arrangement = find(pl, 'Arrangement');
1381 linecolors  = find(pl, 'LineColors');
1382 colors      = find(pl, 'Colors');
1383 linestyles  = find(pl, 'LineStyles');
1384 linewidths  = find(pl, 'LineWidths');
1385 legends     = find(pl, 'Legends');
1386 zlabels     = find(pl, 'ZLabels');
1387 ylabels     = find(pl, 'YLabels');
1388 xlabels     = find(pl, 'XLabels');
1389 xmaths      = find(pl, 'XMaths');
1390 ymaths      = find(pl, 'YMaths');
1391 zmaths      = find(pl, 'ZMaths');
1392 
1393 % check whether we want legends or not
1394 if iscell(legends)
1395   legendsOn = 1;
1396 else
1397   if strcmp(legends, 'off')
1398     legendsOn = 0;
1399   else
1400     legendsOn = 1;
1401     legends = [];
1402   end
1403 end
1404 
1405 % collect figure handles
1406 tsfig = [];
1407 tsax  = [];
1408 tsli  = [];
1409 
1410 % Legend holder
1411 legendStr = [];
1412 
1413 if ~isempty(aos)
1414 
1415   % Now loop over AOs
1416   Na = length(aos);
1417   for j=1:Na
1418     
1419     % Get this AO
1420     a = aos(j);
1421     
1422     % what figures do we need?
1423     switch arrangement
1424       case 'single'        
1425         
1426         tsfig = [tsfig figure];
1427         tsax = subplot(1,1,1);
1428                 
1429       case 'subplots'
1430         
1431         if j == 1, tsfig = figure; end
1432         tsax = [tsax subplot(Na, 1, j)];
1433         
1434       otherwise
1435         error('### Unknown plot arrangement');
1436     end
1437 
1438     %------- Apply math functions
1439     x = a.data.x;
1440     y = a.data.y;
1441     z = a.data.z;
1442     
1443     
1444     ymath = '';
1445     if j<=length(ymaths)
1446       if ~isempty(ymaths{j})
1447         eval(sprintf('y = %s;', ymaths{j}));
1448         ymath = ymaths{j};
1449       end
1450     end
1451     xmath = '';
1452     if j<=length(xmaths)
1453       if ~isempty(xmaths{j})
1454         eval(sprintf('x = %s;', xmaths{j}));
1455         xmath = xmaths{j};
1456       end
1457     end
1458     zmath = '';
1459     if j<=length(zmaths)
1460       if ~isempty(zmaths{j})
1461         eval(sprintf('z = %s;', zmaths{j}));
1462         zmath = zmaths{j};
1463       end
1464     end
1465     
1466     %------- Plot the data
1467     
1468     idcs = pcolor(x,y,z);
1469     tsli = [tsli idcs(1:end).'];
1470     
1471     % plot properties
1472     set(idcs, 'EdgeColor', 'none');
1473     
1474     %------- Axis properties
1475     
1476     % Reverse y-direction for spectrograms
1477     set(tsax(end), 'YDir', 'reverse');
1478     
1479     % Set ylabel
1480     if j<=length(ylabels) && ~isempty(ylabels{j})
1481         ylstr =  ylabels{j};
1482     else
1483       ylstr = find(pl, 'YLabel');
1484     end    
1485     if ~isempty(ymath)
1486       ymath = strrep(ymath, 'y', sprintf('%s', a.data.yunits));
1487       ylstr = [ylstr ' [' ymath ']' ];
1488     else
1489       ylstr = [ylstr ' [' a.data.yunits ']' ];
1490     end
1491     ylabel(ylstr);
1492     
1493     % Set xlabel
1494     if j<=length(xlabels) && ~isempty(xlabels{j})
1495         xlstr =  xlabels{j};
1496     else
1497       xlstr = find(pl, 'XLabel');
1498     end    
1499     if ~isempty(xmath)
1500       xmath = strrep(xmath, 'x', sprintf('%s', a.data.xunits));
1501       xlstr = [xlstr ' [' xmath ']' ];
1502     else
1503       xlstr = [xlstr ' [' a.data.xunits ']' ];
1504     end
1505     xlabel(xlstr);
1506     
1507     % Set grid on or off
1508     grid(tsax(end), 'on');
1509         
1510     % Set title string
1511     if ~strcmpi(legends, 'off')
1512       if j<=length(legends) && ~isempty(legends{j})
1513         legendStr = [legendStr legends(j)];
1514       else
1515         lstr = ltpda_label(a.name);
1516         legendStr = [legendStr cellstr(lstr)];
1517       end
1518     end
1519     
1520     % Set the legend now if we can
1521     tstr = legendStr{end};
1522     if legendsOn
1523       title(tstr);
1524     end
1525     
1526     % Set colorbars
1527     hc = colorbar('peer', tsax(end));
1528     if j<=length(zlabels)
1529       if ~isempty(zlabels{j})
1530         zlstr = zlabels{j};
1531       end
1532     else
1533       zlstr = find(pl, 'Zlabel');
1534     end
1535     if ~isempty(zmath), zlstr = [zlstr sprintf('\n%s', zmath)]; end    
1536     ylh = get(hc, 'YLabel');
1537     set(ylh, 'String', zlstr);
1538     set(ylh, 'Fontsize', get(tsax(end), 'Fontsize'))
1539     set(ylh, 'FontName', get(tsax(end), 'FontName'))
1540     set(ylh, 'FontAngle', get(tsax(end), 'FontAngle'))
1541     set(ylh, 'FontWeight', get(tsax(end), 'FontWeight'))
1542   end
1543 end
1544 
1545 % Set outputs
1546 if nargout > 0
1547   varargout{1} = tsfig;
1548 end
1549 if nargout > 1
1550   varargout{2} = tsax;
1551 end
1552 if nargout == 3
1553   varargout{3} = tsli;
1554 end
1555 if nargout > 3
1556   error('### Too many output arguments');
1557 end
1558 
1559 
1560 %--------------------------------------------------------------------------
1561 % Default Parameter Lists
1562 %
1563 function out = getDefaultPlist(varargin)
1564 
1565 % list of available parameter sets
1566 sets = {'tsdata', 'fsdata', 'cdata', 'xydata'};
1567 
1568 % Get the LTPDA color set for lines
1569 colors = getappdata(0,'ltpda_default_plot_colors');
1570 
1571 if nargin == 0
1572   out = sets;
1573   return
1574 end
1575 
1576 set = varargin{1};
1577 
1578 out = plist('Colors', colors, ...
1579   'Arrangement', 'stacked');
1580 
1581 switch set
1582   case 'fsdata'
1583     out = append(out, 'type', 'fsdata', ...
1584                       'complexPlotType', 'absdeg', ...
1585                       'XLabel', 'Frequency');
1586   case 'tsdata'
1587     out = append(out, 'type', 'tsdata', ...
1588                       'Xlabel', 'Time', ...
1589                       'Ylabel', 'Amplitude');
1590   case 'xydata'
1591     out = append(out, 'type', 'xydata', ...
1592                       'Xlabel', 'X-data', ...
1593                       'Ylabel', 'Y-data', ...
1594                       'YMaths', '', ...
1595                       'XMaths', '');
1596   case 'xyzdata'
1597     out = plist('Colors', colors, 'Arrangement', 'single', ...
1598                       'type', 'xydata', ...
1599                       'Xlabel', 'Time', ...
1600                       'Ylabel', 'Frequency',...
1601                       'Zlabel', 'Amplitude', ...
1602                       'YMaths', '', ...
1603                       'ZMaths', '', ...
1604                       'XMaths', '');
1605   case 'cdata'
1606     out = append(out, 'type', 'tsdata', ...
1607                       'Xlabel', 'Index', ...
1608                       'Ylabel', 'Value');
1609   otherwise
1610     out = plist();
1611 end
1612 
1613 
1614 
1615 
1616 %% OLD BELOW HERE
1617 % function varargout = iplot(varargin)
1618 % % PLOT plots an array of analysis objects.
1619 % %
1620 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1621 % %
1622 % % DESCRIPTION: PLOT plots an array of analysis objects.
1623 % %
1624 % % CALL:
1625 % %
1626 % % PARAMETERS:  complex_view   're/im'   'mag/deg'
1627 % %              title
1628 % %              enbw
1629 % %              legend_names
1630 % %
1631 % % VERSION:     $Id: iplot.m,v 1.25 2008/02/12 09:29:24 mauro Exp $
1632 % %
1633 % % The following call returns a parameter list object that contains the
1634 % % default parameter values:
1635 % %
1636 % % >> pl = plot(ao, 'Params')
1637 % %
1638 % % HISTORY: 21-08-2007 Diepholz
1639 % %             Creation
1640 % %
1641 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1642 %
1643 % VERSION = '$Id: iplot.m,v 1.25 2008/02/12 09:29:24 mauro Exp $';
1644 %
1645 %   %%%%%%%%%%   Check if this is a call for parameters   %%%%%%%%%%
1646 %   if nargin == 2
1647 %     if isa(varargin{1}, 'ao') && ischar(varargin{2})
1648 %       in = char(varargin{2});
1649 %       if strcmp(in, 'Params')
1650 %         varargout{1} = getDefaultPL();
1651 %       elseif strcmp(in, 'Version')
1652 %         varargout{1} = VERSION;
1653 %         return
1654 %       end
1655 %     end
1656 %   end
1657 %
1658 %   axes_handle   = [];
1659 %   ao_s          = [];
1660 %   pl_s          = [];
1661 %   line_spec     = [];
1662 %   prop_val      = {};
1663 %
1664 %   %%%%%%%%%%   Check input values   %%%%%%%%%%
1665 %   var_argin = varargin;
1666 %
1667 %   while ~isempty(var_argin)
1668 %     if ishandle(var_argin{1}) & isempty(axes_handle)
1669 %       axes_handle = var_argin{1};
1670 %       var_argin = var_argin(2:end);
1671 %     elseif isa(var_argin{1}, 'ao')
1672 %       var_argin{1} = reshape(var_argin{1}, 1, []);
1673 %       ao_s = [ao_s var_argin{1}];
1674 %       var_argin = var_argin(2:end);
1675 %     elseif isa(var_argin{1}, 'plist')
1676 %       pl_s = [pl_s var_argin{1}];
1677 %       var_argin = var_argin(2:end);
1678 %     elseif ischar(var_argin{1}) && islinespec(var_argin{1}) && isempty(line_spec)
1679 %       line_spec = var_argin{1};
1680 %       var_argin = var_argin(2:end);
1681 %     else
1682 %       if length(var_argin) == 1
1683 %         error('### There is only one propery [%s] without value left', var_argin{1});
1684 %       elseif length(var_argin) >= 2
1685 %         prop = var_argin{1};
1686 %         val  = var_argin{2};
1687 %         if ismember(prop, {'complex_view', ...
1688 %                            'title_str',    ...
1689 %                            'legend_names', ...
1690 %                            'xlabel_des',   ...
1691 %                            'ylabel_des'})
1692 %           pl_s = [pl_s plist(prop, val)];
1693 %         else
1694 %           prop_val = [prop_val, prop, val];
1695 %         end
1696 %         var_argin = var_argin(3:end);
1697 %       end
1698 %     end
1699 %   end
1700 %
1701 %   pl_s = combine(pl_s, getDefaultPL());
1702 %
1703 %   %%%%%%%%%%  Get default values from the application-defined data.   %%%%%%%%%%
1704 %
1705 %   len_legend  = getappdata(0, 'wraplegendstringat');
1706 %
1707 %   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1708 %   %%           Check some display propeties.           %%
1709 %   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1710 %   sort_ao = [];
1711 %   T0_off  = 1e20;
1712 %
1713 %   for ii = 1:length(ao_s)
1714 %
1715 %     [x,y] = get_xy_values(ao_s(ii).data);
1716 %
1717 %     %%%%%% Get the class name
1718 %     class_name = class(ao_s(ii).data);
1719 %
1720 %     % If the class_name doesn't exist in the variable sort_ao then add this name
1721 %     % as a struct.
1722 %     if isempty(sort_ao) || ~ismember(class_name, fieldnames(sort_ao))
1723 %       sort_ao.(class_name) = [];
1724 %     end
1725 %
1726 %     %%%%%   Define the necessary fields (default values)   %%%%%
1727 %     if isempty(sort_ao.(class_name))
1728 %       sort_ao.(class_name) = struct('ao',            [],      ...
1729 %                                     'complex',       false,   ...
1730 %                                     'complex_view', '',       ...
1731 %                                     'title_str',    '',       ...
1732 %                                     'legend_names', '',       ...
1733 %                                     'xlabel_des',   '',       ...
1734 %                                     'ylabel_des',   '',       ...
1735 %                                     'xscale',       'linear', ...
1736 %                                     'yscale',       'linear', ...
1737 %                                     'enbw',          false);
1738 %     end
1739 %
1740 %     %%%%%   Set the fields for the associated data   %%%%%
1741 %     sort_ao.(class_name).ao = [sort_ao.(class_name).ao ao_s(ii)];
1742 %     sort_ao.(class_name).complex_view = find(pl_s, 'complex_view');
1743 %     sort_ao.(class_name).title_str    = find(pl_s, 'title_str');
1744 %     sort_ao.(class_name).legend_names = find(pl_s, 'legend_names');
1745 %     sort_ao.(class_name).xlabel_des   = find(pl_s, 'xlabel_des');
1746 %     sort_ao.(class_name).ylabel_des   = find(pl_s, 'ylabel_des');
1747 %
1748 %     if ~isreal(y)
1749 %       sort_ao.(class_name).complex = true;
1750 %     end
1751 %     if (max(x)-min(x)) / 10^floor(log10(mean(abs(x)))) > 9
1752 %       sort_ao.(class_name).xscale = 'log';
1753 %     end
1754 %     if min(x) < 0
1755 %       sort_ao.(class_name).xscale = 'linear';
1756 %     end
1757 %     if (max(y)-min(y)) / 10^floor(log10(max(mean(abs(y))))) > 9
1758 %       sort_ao.(class_name).yscale = 'log';
1759 %     end
1760 %     if min(y) < 0
1761 %       sort_ao.(class_name).yscale = 'linear';
1762 %     end
1763 %     if strcmp(class_name, 'tsdata')
1764 %       sort_ao.(class_name).xscale = 'linear';
1765 %     end
1766 %
1767 %
1768 %     %%%%%%%%%%   Spezial fields for the different data objects   %%%%%%%%%%
1769 %
1770 %     %%%%%   FSDATA   %%%%%
1771 %     if strcmp(class_name, 'fsdata')
1772 %       if length (ao_s(ii).data.enbw) > 1
1773 %         sort_ao.(class_name).enbw = find(pl_s, 'enbw');
1774 %       end
1775 %
1776 %       % For fsdata set the x-axis and the y-axis to a logarithmic scale
1777 %       sort_ao.(class_name).xscale = 'log';
1778 %       sort_ao.(class_name).yscale = 'log';
1779 %     end
1780 %
1781 %     %%%%%   TSDATA   %%%%%
1782 %     if strcmp(class_name, 'tsdata')
1783 %
1784 %       t0 = ao_s(ii).data.t0.utc_epoch_milli/1000;
1785 %       if t0 < T0_off
1786 %         T0_off = t0;
1787 %         sort_ao.(class_name).T0_off = t0;
1788 %       end
1789 %     end
1790 %
1791 %   end
1792 %
1793 %   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1794 %   %%           Plot the different data objects           %%
1795 %   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1796 %   fields = fieldnames(sort_ao);
1797 %
1798 %   out_line_h   = [];
1799 %   out_axes_h   = [];
1800 %   out_figure_h = [];
1801 %
1802 %   for ii = 1:length(fields)
1803 %     class_name = fields{ii};
1804 %
1805 %     %%%%%%%%%%   Add the t0 offset to all aos with tsdata objects.   %%%%%%%%%%
1806 %     if strcmp(class_name, 'tsdata')
1807 %       for jj = 1:length(sort_ao.(class_name).ao)
1808 %         curr_ao = sort_ao.(class_name).ao(jj);
1809 %
1810 %         t0 = curr_ao.data.t0.utc_epoch_milli/1000;
1811 %         curr_ao.data.x = curr_ao.data.x + t0 - sort_ao.(class_name).T0_off;
1812 %
1813 %         sort_ao.(class_name).ao(jj) = curr_ao;
1814 %       end
1815 %     end
1816 %
1817 %     %%%%%%%%%%   Set default values   %%%%%%%%%%
1818 %     % Set default title
1819 %     if isempty (sort_ao.(class_name).title_str)
1820 %       if sort_ao.(class_name).complex == true
1821 %         add_text = 'complex ';
1822 %       else
1823 %         add_text = '';
1824 %       end
1825 %       switch (class_name)
1826 %         case 'fsdata'
1827 %           sort_ao.(class_name).title_str = sprintf('Plot of %sfrequency series AOs', add_text);
1828 %         case 'tsdata'
1829 %           sort_ao.(class_name).title_str = sprintf('Plot of %stime series AOs', add_text);
1830 %         case 'cdata'
1831 %           sort_ao.(class_name).title_str = sprintf('Plot of %sconstant data AOs', add_text);
1832 %         case 'xydata'
1833 %           sort_ao.(class_name).title_str = sprintf('Plot of %sxy data AOs', add_text);
1834 %         otherwise
1835 %           error('### Unknown data object ''%s''', class_name);
1836 %       end
1837 %     end
1838 %
1839 %     % Set default x-, y-units
1840 %     if isempty(sort_ao.(class_name).ao(1).data.xunits)
1841 %       xunits = 'unknown';
1842 %     else
1843 %       xunits= sort_ao.(class_name).ao(1).data.xunits;
1844 %     end
1845 %     if isempty(sort_ao.(class_name).ao(1).data.yunits)
1846 %       yunits = 'unknown';
1847 %     else
1848 %       yunits= sort_ao.(class_name).ao(1).data.yunits;
1849 %     end
1850 %
1851 %     fig_h = gcf;
1852 %
1853 %     %%%%%%%%%%   Plot complex values   %%%%%%%%%%
1854 %     if sort_ao.(class_name).complex == true
1855 %
1856 %       if strcmp(sort_ao.(class_name).complex_view, 're/im')
1857 %         axes_h1 = subplot(2,1,1);
1858 %         line_h1 = plot(axes_h1, real(sort_ao.(class_name).ao), line_spec, prop_val{:});
1859 %         axes_h2 = subplot(2,1,2);
1860 %         line_h2 = plot(axes_h2, imag(sort_ao.(class_name).ao), line_spec, prop_val{:});
1861 %
1862 %         label_x1 = [sort_ao.(class_name).xlabel_des ' [' xunits ']'];
1863 %         label_y1 = [sort_ao.(class_name).ylabel_des 'Real [' yunits ']'];
1864 %         label_y2 = [sort_ao.(class_name).ylabel_des 'Imaginary [' yunits ']'];
1865 %
1866 %         % Do not set the xscale if it is set as a propertie/value pair
1867 %         if ~ismember('xscale', lower(prop_val))
1868 %           % If the 'key' exist in the parameter list then do NOT replace the
1869 %           % value. (see combine) If the user use a different syntax (he use
1870 %           % upper case letters) this value is put before the user value.
1871 %           % This function take ALWAYS the user value.
1872 %           pl_s = combine(pl_s, plist('xscale', sort_ao.(class_name).xscale));
1873 %         end
1874 %
1875 %         % Plot both y-axes as a linear scale
1876 %         pl_s = pset(pl_s, 'Yscale', 'linear');
1877 %
1878 %       else % if strcmp(sort_ao.(class_name).complex_view, 'mag/deg')
1879 %         axes_h1 = subplot(3,1,1:2);
1880 %         line_h1 = plot(axes_h1, abs(sort_ao.(class_name).ao), line_spec, prop_val{:});
1881 %         axes_h2 = subplot(3,1,3);
1882 %         line_h2 = plot(axes_h2, phase(sort_ao.(class_name).ao), line_spec, prop_val{:});
1883 %
1884 %         label_x1 = [sort_ao.(class_name).xlabel_des ' [' xunits ']'];
1885 %         label_y1 = [sort_ao.(class_name).ylabel_des 'Magnitude [' yunits ']'];
1886 %         label_y2 = [sort_ao.(class_name).ylabel_des 'Phase [' yunits ']'];
1887 %
1888 %         % Do not set the xscale if it is set as a propertie/value pair
1889 %         if ~ismember('xscale', lower(prop_val))
1890 %           % If the 'key' exist in the parameter list then do NOT replace the
1891 %           % value. (see combine) If the user use a different syntax (he use
1892 %           % upper case letters) this value is put before the user value.
1893 %           % This function take ALWAYS the user value.
1894 %           pl_s = combine(pl_s, plist('xscale', sort_ao.(class_name).xscale));
1895 %         end
1896 %
1897 %         % Do not set the yscale if it is set as a propertie/value pair
1898 %         if ~ismember('yscale', lower(prop_val))
1899 %           % If the 'key' exist in the parameter list then do NOT replace the
1900 %           % value. (see combine) If the user use a different syntax (he use
1901 %           % upper case letters) this value is put before the user value.
1902 %           % This function take ALWAYS the user value.
1903 %           pl_s = combine(pl_s, plist('yscale', sort_ao.(class_name).yscale));
1904 %         end
1905 %
1906 %         % Plot always the second y-axes as a linear scale
1907 %         pl_s = pset(pl_s, 'Yscale2', 'linear');
1908 %       end
1909 %
1910 %       % Set x-, y-label
1911 %       xlabel(axes_h2, label_x1);
1912 %       ylabel(axes_h1, label_y1);
1913 %       ylabel(axes_h2, label_y2);
1914 %
1915 %       out_line_h   = [out_line_h,   line_h1, line_h2];
1916 %       out_axes_h   = [out_axes_h,   axes_h1, axes_h2];
1917 %       out_figure_h = [out_figure_h, fig_h];
1918 %
1919 %     %%%%%%%%%%   Plot real values   %%%%%%%%%%
1920 %     else
1921 %
1922 %       [line_h1, axes_h1] = plot(real(sort_ao.(class_name).ao), line_spec, prop_val{:});
1923 %
1924 %       axes_h2 = axes_h1;
1925 %       line_h2 = line_h1;
1926 %
1927 %       % Set x-, y-label
1928 %       xlabel(axes_h1, [sort_ao.(class_name).xlabel_des ' [' xunits ']']);
1929 %       ylabel(axes_h1, [sort_ao.(class_name).ylabel_des ' [' yunits ']']);
1930 %
1931 %       out_line_h   = [out_line_h,   line_h1];
1932 %       out_axes_h   = [out_axes_h,   axes_h1];
1933 %       out_figure_h = [out_figure_h, fig_h];
1934 %
1935 %       % Do not set the xscale if it is set as a propertie/value pair
1936 %       if ~ismember('xscale', lower(prop_val))
1937 %         % If the 'key' exist in the parameter list then do NOT replace the
1938 %         % value. (see combine) If the user use a different syntax (he use
1939 %         % upper case letters) this value is put before the user value.
1940 %         % This function take ALWAYS the user value.
1941 %         pl_s = combine(pl_s, plist('xscale', sort_ao.(class_name).xscale));
1942 %       end
1943 %
1944 %       % Do not set the yscale if it is set as a propertie/value pair
1945 %       if ~ismember('yscale', lower(prop_val))
1946 %         % If the 'key' exist in the parameter list then do NOT replace the
1947 %         % value. (see combine) If the user use a different syntax (he use
1948 %         % upper case letters) this value is put before the user value.
1949 %         % This function take ALWAYS the user value.
1950 %         pl_s = combine(pl_s, plist('yscale', sort_ao.(class_name).yscale));
1951 %       end
1952 %
1953 %     end % if complex == true
1954 %
1955 %     %%%%%%%%%%   Set Title     %%%%%%%%%%
1956 %     title (axes_h1, sort_ao.(class_name).title_str);
1957 %
1958 %     %%%%%%%%%%   Set Title     %%%%%%%%%%
1959 %     grid(axes_h1, 'on');
1960 %     grid(axes_h2, 'on');
1961 %
1962 %     %%%%%%%%%%   Set legend names   %%%%%%%%%%
1963 %     % Use the ao names for the legend
1964 %     if isempty(sort_ao.(class_name).legend_names)
1965 %       for jj = 1:length(sort_ao.(class_name).ao)
1966 %
1967 %         display_name = sort_ao.(class_name).ao(jj).name;
1968 %         display_name = ltpda_label(display_name);
1969 %         display_name = wrapLegendString(sprintf('%s', ltpda_label(display_name)), len_legend);
1970 %         set(line_h1(jj), 'DisplayName', ltpda_label(display_name))
1971 %       end
1972 %       legend(axes_h1, 'toggle')
1973 %       % Use the legend names from the plist
1974 %     else
1975 %       legend(axes_h1, sort_ao.(class_name).legend_names);
1976 %     end
1977 %
1978 %     %%%%%%%%%%   Set axes OR lineseries properties from the plist   %%%%%%%%%%
1979 %     for jj = 1:length(pl_s.params)
1980 %       p = pl_s.params(jj);
1981 %
1982 %       [idx_b, idx_e, dummy, match] = regexp(p.key, '\d', 'once');
1983 %       p.key = strrep(p.key, match, '');
1984 %
1985 %       % Check key to the axes property
1986 %       if isprop(line_h1, p.key)
1987 %         if strcmp(match, '1')
1988 %           set(line_h1, p.key, p.val);
1989 %         elseif strcmp(match, '2')
1990 %           set(line_h2, p.key, p.val);
1991 %         else
1992 %           set(line_h1, p.key, p.val);
1993 %           set(line_h2, p.key, p.val);
1994 %         end
1995 %       % Check key to the axes property
1996 %       elseif isprop(axes_h1, p.key)
1997 %         if strcmp(match, '1')
1998 %           set(axes_h1, p.key, p.val);
1999 %         elseif strcmp(match, '2')
2000 %           set(axes_h2, p.key, p.val);
2001 %         else
2002 %           set(axes_h1, p.key, p.val);
2003 %           set(axes_h2, p.key, p.val);
2004 %         end
2005 %       end
2006 %
2007 %     end
2008 %
2009 %   end
2010 %
2011 %
2012 %   %%%%%%%%%%   varargout{1} = line   handle   %%%%%%%%%%
2013 %   %%%%%%%%%%   varargout{2} = axes   handle   %%%%%%%%%%
2014 %   %%%%%%%%%%   varargout{3} = figure handle   %%%%%%%%%%
2015 %
2016 %   if nargout == 0
2017 %   elseif nargout == 1
2018 %     varargout{1} = out_line_h;
2019 %   elseif nargout == 2
2020 %     varargout{1} = out_line_h;
2021 %     varargout{2} = out_axes_h;
2022 %   elseif nargout == 3
2023 %     varargout{1} = out_line_h;
2024 %     varargout{2} = out_axes_h;
2025 %     varargout{3} = out_figure_h;
2026 %   else
2027 %     error('### Unknown number of outputs.')
2028 %   end
2029 %
2030 %
2031 % end % function varargout = iplot(varargin)
2032 %
2033 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2034 % %
2035 % % DESCRIPTION: GETDEFAULTLIST retuns the default parameter list.
2036 % %
2037 % % CALL:        pl_default = getDefaultPL()
2038 % %
2039 % % HISTORY:     21-08-2007 Diepholz
2040 % %                 Creation
2041 % %
2042 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2043 % function pl_default = getDefaultPL()
2044 %
2045 %   pl_default = plist();
2046 %   pl_default = append(pl_default, 'complex_view', 'mag/deg');
2047 %   pl_default = append(pl_default, 'enbw',          false);
2048 % end
2049 %
2050 %
2051 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2052 % %
2053 % % DESCRIPTION: WRAPLEGENDSTRING wrap a legend string into multiple lines.
2054 % %
2055 % % CALL:        so = wrapLegendString(s, N)
2056 % %
2057 % % HISTORY:     21-08-2007 M Hewitson
2058 % %                 Creation
2059 % %
2060 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2061 % function so = wrapLegendString(s, N)
2062 %   % get cells
2063 %   sc = wrapstring(s, N);
2064 %
2065 %   so = sc{1};
2066 %
2067 %   for j=2:length(sc)
2068 %     so = [so sprintf('\n%s', sc{j})];
2069 %   end
2070 % end
2071 %
2072 %
2073 %
2074 %

Generated on Fri 07-Mar-2008 15:46:43 by m2html © 2003