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(...)

 VERSION:     $Id: plot.m,v 1.30 2007/10/24 17:35:28 ingo Exp $

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

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

 HISTORY:      16-08-2007 M Diepholz
                  Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Fri 02-Nov-2007 19:39:27 by m2html © 2003