Home > chronux_1_1 > spikesort > utility > graphicstyles > nice.m

nice

PURPOSE ^

NICE Custom plot prettification.

SYNOPSIS ^

function nice

DESCRIPTION ^

NICE              Custom plot prettification.
   The function NICE is a macro for Matlab graphics settings, and its
   behavior depends on the contents of the current axes.

   If the plot contains only 2-D (i.e., empty ZData) line objects NICE
   sets the Y-limits depending on the data:
               Data Range        Gives Limits
                [ 0,1]           [-0.2 1.2]
                [-1,1]           [-1.2 1.2]
                [ 0,B]           [-0.1 1.2]*B
                [-A,B]           [-1.2 1.2]*C, where C=MAX(ABS(A,B))
   where the first condition that matches is used.

   If the plot contains surface/patch objects, 3-D visualization aids are
   set, including: two lights, interpolated shading (if possible), and
   constant view angle for 3-D rotation.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function nice
0002 %NICE              Custom plot prettification.
0003 %   The function NICE is a macro for Matlab graphics settings, and its
0004 %   behavior depends on the contents of the current axes.
0005 %
0006 %   If the plot contains only 2-D (i.e., empty ZData) line objects NICE
0007 %   sets the Y-limits depending on the data:
0008 %               Data Range        Gives Limits
0009 %                [ 0,1]           [-0.2 1.2]
0010 %                [-1,1]           [-1.2 1.2]
0011 %                [ 0,B]           [-0.1 1.2]*B
0012 %                [-A,B]           [-1.2 1.2]*C, where C=MAX(ABS(A,B))
0013 %   where the first condition that matches is used.
0014 %
0015 %   If the plot contains surface/patch objects, 3-D visualization aids are
0016 %   set, including: two lights, interpolated shading (if possible), and
0017 %   constant view angle for 3-D rotation.
0018 
0019 
0020 %%%%%%%%%%%%%% Actually, it doesn't do the following for now ... not sure what the best thing is
0021 %       The X-limits are set similarly if the X-values are not uniformly spaced;
0022 %       Uniformly spaced x-values cause the X-limits to be set between the min
0023 %       X-value - 1 and the max X-value + 1.
0024 
0025 childs = get(gca, 'Children');
0026 if (length(childs) == 1),  childs = childs([1,1]);  end;        % ensure get(childs, prop) always returns cell
0027 childs(ismember(get(childs, 'Type'), {'text', 'light'})) = [];  % ignore these
0028 childtypes = get(childs, 'Type');
0029 
0030 if (all(strcmp(childtypes, 'line')))
0031     
0032     twoD = cellfun('isempty', get(childs, {'ZData'}));
0033     if (all(twoD))
0034         ydata = get(childs, 'YData');   ydata = cat(2, ydata{:});
0035         xdata = get(childs, 'XData');   xdata = cat(2, xdata{:});
0036         
0037         miny = min(ydata);  maxy = max(ydata);
0038         maxabs    = max(abs([miny,maxy,1]));
0039         if (miny < 0),   ylim = [-1.2, 1.2]*maxabs;
0040         else,            ylim = [-0.2, 1.2]*maxabs;
0041         end
0042 
0043         xlim = [min(xdata)-1, max(xdata)+1];   % temporary -- just tightens the X limits.
0044         
0045         set(gca, 'YLim', ylim, 'XLim', xlim);
0046         zoom reset;
0047     end
0048     
0049 elseif (any(ismember(childtypes, {'surface', 'patch'})))
0050     childs(strcmp(childtypes, 'line')) = [];
0051     
0052     axis tight;  set(gca,'CameraViewAngleMode','manual', 'CameraViewAngle', 9);
0053 
0054     interpable = ~cellfun('isempty', get(childs, {'CData'}));
0055     set(childs(interpable), 'FaceColor', 'interp', 'EdgeColor', 'none');
0056 
0057     material dull;    
0058     lighting gouraud;   % not as nice as phong lighting, but faster to render
0059     lightangle(90,60);  lightangle(270,10);
0060     
0061 end

Generated on Sun 13-Aug-2006 11:49:44 by m2html © 2003