function color_fig
%color_fig
%This is called from surface_plot.m and is sets the colormap on the
%current graphics figure and the one before it. This is because we
%require the principal figure and its legend to use the same color
%map.  It is assumed that the global HPOP contains the handle to a
%uicontrol created 'user interface control' that specifies the
%desired colormap.  The other globals (POSNEG_N & POSNEG_P) are also
%set in surface_plot.m and define the the number of colormap rows that
%are negative & positive
%assuming a 64 row colormap.  These values are used in the posneg
%colormap where all negative values are dark gray and all positive
%ones a lighter gray.  Note that because because the colormap has a
% finite number of rows then some values very near to zero can be
% mapped to the wrong shade of gray.

%     Copyright J. V. Mansbridge, CSIRO, july  2 1993

global HPOP POSNEG_N POSNEG_P
val = get(HPOP, 'Value');
h = gcf;
if val == 1
  colormap(hsv)
elseif val == 2
  colormap(hot)
elseif val == 3
  colormap(cool)
elseif val == 4
  colormap(jet)
elseif val == 5
  colormap(pink)
elseif val == 6
  colormap(gray)
elseif val == 7
  if POSNEG_P == 0
    posneg = 0.3*ones(POSNEG_N, 3);
  elseif POSNEG_N == 0
    posneg = 0.3*ones(POSNEG_P, 3);
  else
    posneg = [ 0.3*ones(POSNEG_N, 3); 0.6*ones(POSNEG_P, 3) ];
  end
  colormap(posneg)
end
