Home > classes > @ao > simple_plot.m

simple_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: simple_plot.m,v 1.7 2007/08/24 12:33:34 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: simple_plot.m,v 1.7 2007/08/24 12:33:34 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   axes_handle = [];
0030   ao_s        = [];
0031   line_spec   = '';
0032   prop_val    = {};
0033   lines_h     = [];
0034 
0035   %%%%%%%%%%   Check if this is a call for parameters   %%%%%%%%%%
0036   if nargin == 2
0037     if isa(varargin{1}, 'ao') && ischar(varargin{2})
0038       in = char(varargin{1});
0039       if strcmp(in, 'Params')
0040         varargout{1} = plist();
0041         return
0042       end
0043     end
0044   end
0045 
0046   %%%%%%%%%%   Check input values    %%%%%%%%%%
0047   for ii = 1:nargin
0048     if ishandle(varargin{ii}) & isempty(axes_handle)
0049       axes_handle = varargin{ii};
0050     elseif isa(varargin{ii}, 'ao')
0051       varargin{ii} = reshape(varargin{ii}, 1, []);
0052       ao_s = [ao_s varargin{ii}];
0053     elseif ischar(varargin{ii}) && islinespec(varargin{ii}) && isempty(line_spec)
0054       line_spec = varargin{ii};
0055     else
0056       prop_val = [prop_val, varargin{ii}];
0057     end
0058   end
0059 
0060   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0061   %            For all ao_s            %
0062   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0063   for ii = 1:length(ao_s)
0064 
0065     %%%%%%%%%%   Setthe line colors   %%%%%%%%%%
0066     line_colors = getappdata(0, 'ltpda_default_plot_colors');
0067 
0068     %%% Set only the color if the color is not set in the linespec
0069     [res, style] = islinespec(line_spec);
0070 
0071     if isempty(style{3})
0072       prop_val{end+1} = 'Color';
0073       prop_val{end+1} = line_colors{ii};
0074     end
0075 
0076     %%%%%%%%%%   Get the x-, y-values   %%%%%%%%%%
0077     [x,y] = get_xy_axis(ao_s(ii).data);
0078 
0079     if isreal(y)
0080       if isempty(x)
0081         x = 1:length(y);
0082       end
0083     else % iscomplex(y)
0084       if isempty(x)
0085         x = real(y);
0086         y = imag(y);
0087       end
0088     end
0089 
0090     %%%%%%%%%%   Call the different plot command lines   %%%%%%%%%%
0091     if ~isempty(axes_handle) && ~isempty(line_spec)
0092       line_h = plot(axes_handle, x, y, line_spec);
0093     elseif ~isempty(axes_handle)
0094       line_h = plot(axes_handle, x, y);
0095     elseif ~isempty(line_spec)
0096       line_h = plot(x, y, line_spec);
0097     else
0098       line_h = plot(x, y);
0099     end
0100 
0101     hold on;
0102 
0103     line_h  = reshape(line_h, 1, []);
0104     lines_h = [lines_h line_h];
0105 
0106     %%%%%%%%%%   Set the different handles: axes- and figure- handle   %%%%%%%%%%
0107     axes_h   = get(line_h(1), 'Parent');
0108     figure_h = get(axes_h,    'Parent');
0109 
0110     %%%%%%%%%%   Set line series Properties OR axes Properties   %%%%%%%%%%
0111     while length(prop_val) >= 2
0112       prop = prop_val{1};
0113       val  = prop_val{2};
0114       prop_val = prop_val(3:end);
0115       if isprop(line_h, prop)
0116         set(line_h, prop, val);
0117       else
0118         if isprop(axes_h, prop)
0119           set(axes_h, prop, val);
0120         else
0121           error('### Invalid line property OR axes property: ''%s''.', prop);
0122         end
0123       end
0124     end
0125 
0126   end % for ii = 1:length(ao_s)
0127 
0128 
0129   %%%%%%%%%%   varargout{1} = line   handle   %%%%%%%%%%
0130   %%%%%%%%%%   varargout{2} = axes   handle   %%%%%%%%%%
0131   %%%%%%%%%%   varargout{3} = figure handle   %%%%%%%%%%
0132   if nargout == 0 
0133   elseif nargout == 1
0134     varargout{1} = lines_h;
0135   elseif nargout == 2
0136     varargout{1} = lines_h;
0137     varargout{2} = axes_h;
0138   elseif nargout == 3
0139     varargout{1} = lines_h;
0140     varargout{2} = axes_h;
0141     varargout{3} = figure_h;
0142   else
0143     error('### Unknown number of outputs.')
0144   end
0145 
0146   hold off;
0147 
0148 end % function varargout = plot(varargin)
0149 
0150 
0151 
0152 
0153 
0154 
0155

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003