Home > chronux_1_15 > spikesort > utility > plottypes > errorarea.m

errorarea

PURPOSE ^

ERRORAREA Plot with confidence region.

SYNOPSIS ^

function [linehandles, patchhandles] = errorarea(x,y,l,u)

DESCRIPTION ^

ERRORAREA         Plot with confidence region.
   ERRORAREA(X,Y,L,U) is similar to ERRORBAR(X,Y,L,U), except that the
   confidence bounds are drawn as a shaded patch above and below the
   plot.  ERRORAREA(X,Y,E) and ERRORAREA(Y,E) are similarly allowed and
   are analagous to their ERRORBAR equivalents.

   [LINEHANDLE,PATCHHANDLE] = ERRORAREA(...) returns handles to the line
   and patch objects.

   See also ERRORBAR.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [linehandles, patchhandles] = errorarea(x,y,l,u)
0002 %ERRORAREA         Plot with confidence region.
0003 %   ERRORAREA(X,Y,L,U) is similar to ERRORBAR(X,Y,L,U), except that the
0004 %   confidence bounds are drawn as a shaded patch above and below the
0005 %   plot.  ERRORAREA(X,Y,E) and ERRORAREA(Y,E) are similarly allowed and
0006 %   are analagous to their ERRORBAR equivalents.
0007 %
0008 %   [LINEHANDLE,PATCHHANDLE] = ERRORAREA(...) returns handles to the line
0009 %   and patch objects.
0010 %
0011 %   See also ERRORBAR.
0012 
0013 % Parse the data arguments
0014 if (min(size(x)) == 1),  x = x(:);  end;
0015 [npts,nlns] = size(x);
0016 switch (nargin),
0017     case 4,   % do nothing
0018     case 3,   u = l;
0019     case 2,   l = y;  u = y;  y = x;  x = [1:npts]' * ones(1,nlns);
0020     otherwise,  error('Invalid syntax.');
0021 end
0022 if (nlns == 1),  y = y(:); l = l(:); u = u(:);  end;
0023 if (~isequal(size(x), size(y), size(u), size(l)))
0024     error('The sizes of X, Y, L and U must be the same.');
0025 end
0026 
0027 
0028 % Plot the main line
0029 linehandles = plot(x,y);
0030 
0031 % Plot the error patches ...
0032 patchhandles = zeros(1,nlns);
0033 for ln = 1:nlns
0034     xwrap = [x(:,ln)',fliplr(x(:,ln)')];
0035     ywrap = [(y(:,ln)+u(:,ln))', flipud(y(:,ln)-l(:,ln))'];
0036     patchhandles(ln) = patch(xwrap, ywrap, get(linehandles(ln), 'Color'), ...
0037                              'EdgeColor', 'none', 'FaceAlpha', 0.25);
0038 end
0039 
0040 if (nargout == 0)
0041     clear linehandles patchhandles
0042 end

Generated on Tue 15-Aug-2006 22:51:57 by m2html © 2003