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.
 
             'LineColors' - a cell array of color definitions for each line.
 
             'LineStyles' - a cell array of line styles. 
 
             'Markers'    - a cell array of markers. 
 
             'LineWidths' - an array of line widths. If the length of the
                            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.
 
             '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.
 
 
 
 VERSION:     $Id: iplot.m,v 1.17 2008/01/21 11:40:25 hewitson Exp $

 The following call returns a parameter list object that contains the
 default parameter values:

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

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

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003