Home > classes > @ao > plot.m

plot

PURPOSE ^

PLOT a simple plot of analysis objects.

SYNOPSIS ^

function varargout = plot(varargin)

DESCRIPTION ^

 PLOT a simple plot of analysis objects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: PLOT a simple plot of analysis objects.

 CALL:        plot(ao)
              plot(ao,LineSpec)
              plot(axes_handle, ao)
              plot(axes_handle, ao, LineSpec)
              plot(...,'PropertyName',PropertyValue,...)
              [line_h]                   = plot(...)
              [line_h, axes_h]           = plot(...)
              [line_h, axes_h, figure_h] = plot(...)

 M-FILE INFO: Get information about this methods by calling
              >> ao.getInfo('plot')

              Get information about a specified set-plist by calling:
              >> ao.getInfo('plot', 'None')

 VERSION:     $Id: plot.m,v 1.36 2008/09/05 11:05:29 ingo Exp $

 HISTORY:     16-08-2007 Diepholz
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % PLOT a simple plot of analysis objects.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: PLOT a simple plot of analysis objects.
0005 %
0006 % CALL:        plot(ao)
0007 %              plot(ao,LineSpec)
0008 %              plot(axes_handle, ao)
0009 %              plot(axes_handle, ao, LineSpec)
0010 %              plot(...,'PropertyName',PropertyValue,...)
0011 %              [line_h]                   = plot(...)
0012 %              [line_h, axes_h]           = plot(...)
0013 %              [line_h, axes_h, figure_h] = plot(...)
0014 %
0015 % M-FILE INFO: Get information about this methods by calling
0016 %              >> ao.getInfo('plot')
0017 %
0018 %              Get information about a specified set-plist by calling:
0019 %              >> ao.getInfo('plot', 'None')
0020 %
0021 % VERSION:     $Id: plot.m,v 1.36 2008/09/05 11:05:29 ingo Exp $
0022 %
0023 % HISTORY:     16-08-2007 Diepholz
0024 %                 Creation
0025 %
0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0027 
0028 function varargout = plot(varargin)
0029 
0030   % Check if this is a call for parameters
0031   if utils.helper.isinfocall(varargin{:})
0032     varargout{1} = getInfo(varargin{3});
0033     return
0034   end
0035 
0036   import utils.const.*
0037   utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename);
0038   
0039   axes_handle = [];
0040   ao_s        = [];
0041   line_spec   = '';
0042   prop_val    = {};
0043   lines_h     = [];
0044 
0045   %%%%%%%%%%   Check input values    %%%%%%%%%%
0046   var_argin = varargin;
0047 
0048   while ~isempty(var_argin)
0049     if isempty(var_argin{1})
0050       var_argin = var_argin(2:end);
0051     elseif ishandle(var_argin{1}) && isempty(axes_handle)
0052       axes_handle = var_argin{1};
0053       var_argin = var_argin(2:end);
0054     elseif isa(var_argin{1}, 'ao')
0055       var_argin{1} = reshape(var_argin{1}, 1, []);
0056       ao_s = [ao_s var_argin{1}];
0057       var_argin = var_argin(2:end);
0058     elseif ischar(var_argin{1}) && islinespec(var_argin{1}) && isempty(line_spec)
0059       line_spec = var_argin{1};
0060       var_argin = var_argin(2:end);
0061     else
0062       if length(var_argin) == 1
0063         error('### There is only one propery [%s] without value left', var_argin{1});
0064       elseif length(var_argin) >= 2
0065         prop = var_argin{1};
0066         val  = var_argin{2};
0067         prop_val  = [prop_val, prop, val];
0068         var_argin = var_argin(3:end);
0069       end
0070     end
0071   end
0072 
0073   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0074   %            For all ao_s            %
0075   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0076   for ii = 1:length(ao_s)
0077 
0078     %%%%%%%%%%   Setthe line colors   %%%%%%%%%%
0079     line_colors = getappdata(0, 'ltpda_default_plot_colors');
0080 
0081     %%% Set only the color if the color is not set in the linespec
0082     [res, style] = islinespec(line_spec);
0083 
0084     if isempty(style{3})
0085       prop_val{end+1} = 'Color';
0086       prop_val{end+1} = line_colors{ii};
0087     end
0088 
0089     %%%%%%%%%%   Get the x-, y-values   %%%%%%%%%%
0090     x = ao_s(ii).data.getX;
0091     y = ao_s(ii).data.y;
0092 
0093     if isreal(y)
0094       if isempty(x)
0095         x = 1:length(y);
0096       end
0097     else % iscomplex(y)
0098       if isempty(x)
0099         x = real(y);
0100         y = imag(y);
0101       end
0102     end
0103 
0104     %%%%%%%%%%   Call the different plot command lines   %%%%%%%%%%
0105     if ~isempty(axes_handle) && ~isempty(line_spec)
0106       line_h = plot(axes_handle, x, y, line_spec);
0107     elseif ~isempty(axes_handle)
0108       line_h = plot(axes_handle, x, y);
0109     elseif ~isempty(line_spec)
0110       line_h = plot(x, y, line_spec);
0111     else
0112       line_h = plot(x, y);
0113     end
0114 
0115     hold on;
0116 
0117     line_h  = reshape(line_h, 1, []);
0118     lines_h = [lines_h line_h];
0119 
0120     %%%%%%%%%%   Set the different handles: axes- and figure- handle   %%%%%%%%%%
0121     axes_h   = get(line_h(1), 'Parent');
0122     figure_h = get(axes_h,    'Parent');
0123 
0124     %%%%%%%%%%   Set line series Properties OR axes Properties   %%%%%%%%%%
0125     while length(prop_val) >= 2
0126       prop = prop_val{1};
0127       val  = prop_val{2};
0128       prop_val = prop_val(3:end);
0129       if isprop(line_h, prop)
0130         set(line_h, prop, val);
0131       else
0132         if isprop(axes_h, prop)
0133           set(axes_h, prop, val);
0134         else
0135           error('### Invalid line property OR axes property: ''%s''.', prop);
0136         end
0137       end
0138     end
0139 
0140   end % for ii = 1:length(ao_s)
0141 
0142 
0143   %%%%%%%%%%   varargout{1} = line   handle   %%%%%%%%%%
0144   %%%%%%%%%%   varargout{2} = axes   handle   %%%%%%%%%%
0145   %%%%%%%%%%   varargout{3} = figure handle   %%%%%%%%%%
0146   if nargout == 0
0147   elseif nargout == 1
0148     varargout{1} = lines_h;
0149   elseif nargout == 2
0150     varargout{1} = lines_h;
0151     varargout{2} = axes_h;
0152   elseif nargout == 3
0153     varargout{1} = lines_h;
0154     varargout{2} = axes_h;
0155     varargout{3} = figure_h;
0156   else
0157     error('### Unknown number of outputs.')
0158   end
0159 
0160   hold off;
0161 
0162 end
0163 
0164 %--------------------------------------------------------------------------
0165 % Get Info Object
0166 %--------------------------------------------------------------------------
0167 function ii = getInfo(varargin)
0168   if nargin == 1 && strcmpi(varargin{1}, 'None')
0169     sets = {};
0170     pl   = [];
0171   else
0172     sets = {'Default'};
0173     pl   = getDefaultPlist;
0174   end
0175   % Build info object
0176   ii = minfo(mfilename, 'ao', '', utils.const.categories.output, '$Id: plot.m,v 1.36 2008/09/05 11:05:29 ingo Exp $', sets, pl);
0177 end
0178 
0179 %--------------------------------------------------------------------------
0180 % Get Default Plist
0181 %--------------------------------------------------------------------------
0182 function pl = getDefaultPlist()
0183   pl = plist();
0184 end
0185 
0186 % END
0187 
0188

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003