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:

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

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003