Home > chronux_1_1 > spikesort > utility > hgtools > HGcolorshift.m

HGcolorshift

PURPOSE ^

HGcolorshift Creates an interactive colorbar.

SYNOPSIS ^

function h = HGcolorshift(varargin)

DESCRIPTION ^

HGcolorshift      Creates an interactive colorbar.
   HGcolorshift adds a (vertical) colorbar to the current axes.  This
   colorbar can be used to shift or rescale the color mapping in the
   current axes.  Clicking near the top of the colorbar axes
   up or down (right or left for horizontal colorbars) changes the value
   mapped to the top color scale limit. Similarly, clicking near the
   bottom changes the value mapped to the bottom color scale limit.

   Clicking elsewhere and dragging cyclically shifts the color map.  This
   shift is applied to the whole figure.

   HGcolorshift(ARG1,...) takes the same arguments as COLORBAR.

   H = HGcolorshift(...) returns a handle to the colorbar axes.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function h = HGcolorshift(varargin)
0002 %HGcolorshift      Creates an interactive colorbar.
0003 %   HGcolorshift adds a (vertical) colorbar to the current axes.  This
0004 %   colorbar can be used to shift or rescale the color mapping in the
0005 %   current axes.  Clicking near the top of the colorbar axes
0006 %   up or down (right or left for horizontal colorbars) changes the value
0007 %   mapped to the top color scale limit. Similarly, clicking near the
0008 %   bottom changes the value mapped to the bottom color scale limit.
0009 %
0010 %   Clicking elsewhere and dragging cyclically shifts the color map.  This
0011 %   shift is applied to the whole figure.
0012 %
0013 %   HGcolorshift(ARG1,...) takes the same arguments as COLORBAR.
0014 %
0015 %   H = HGcolorshift(...) returns a handle to the colorbar axes.
0016 
0017 %%%%%%%%%%%%%%%%%%%%%%%%% Create the Colorbar %%%%%%%%%%%%%%%%%%%%%%%%
0018 target = gca;
0019 fighdl = gcf;
0020 colorbar(varargin{:});  % create or refresh an existing colorbar
0021 
0022 %%%%%%%%%%%%%%%%%%%%% Get a handle to the Colorbar %%%%%%%%%%%%%%%%%%%
0023 h = find_colorbar(target);
0024 cimage = findobj(h, 'Type', 'image');
0025 
0026 cbar_pos = get(h, 'Position');
0027 ax_pos   = get(target, 'Position');
0028 if (cbar_pos(1) > sum(ax_pos([1,3]))),   mode = 'V';
0029 else,                                    mode = 'H';
0030 end
0031 
0032 %%%%%%%%%%%%%%%%%%%%%%%%% Assign the Callback %%%%%%%%%%%%%%%%%%%%%%%%
0033 userdata = get(h,'UserData');
0034 userdata.fighdl = fighdl;
0035 userdata.cbrhdl = h;
0036 userdata.target = target;
0037 userdata.cimage = cimage;
0038 userdata.mode   = mode;
0039 set(h, 'UserData', userdata, 'ButtonDownFcn', @CB_colorshift);
0040 
0041 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Cleanup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0042 if (nargout == 0), clear h;  end
0043 axes(target);   % reset current axes

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