From octave-sources-request at bevo dot che dot wisc dot edu Thu Nov 15 11:01:41 2001 Subject: cool and hot colormaps From: Felipe Bertrand To: octave-sources at bevo dot che dot wisc dot edu Date: Thu, 15 Nov 2001 12:01:38 -0500 --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Here are 2 functions to build the equivalent to matlabs "cool" and "hot" colormaps. Felipe -- Felipe Bertrand fbertrand at ieee dot org --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="cool.m" ## Copyright (C) 1996, 1997 John W. Eaton ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2, or (at your option) ## any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, write to the Free ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. ## -*- texinfo -*- ## at deftypefn {Function File} {} cool (@var{n}) ## Create color (cyan and magenta) colormap. ## The argument at var{n} should be a scalar. If it ## is omitted, 64 is assumed. ## at end deftypefn ## Author: Tony Richardson ## Created: July 1994 ## Adapted-By: jwe ## Adapted-By: Felipe Bertrand function map = cool (number) if (nargin == 0) number = 64; elseif (nargin == 1) if (! is_scalar (number)) error ("cool: argument must be a scalar"); end else usage ("cool (number)"); end dr = 1 / (number-1); r = postpad([0:dr:1],number,1)'; g = r(number:-1:1); b = ones(number,1); map = [ r, g, b ]; endfunction --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="hot.m" ## Copyright (C) 1996, 1997 John W. Eaton ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2, or (at your option) ## any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, write to the Free ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. ## -*- texinfo -*- ## at deftypefn {Function File} {} hot (@var{n}) ## Create color (black->red->yellow->white) colormap. ## The argument at var{n} should be a scalar. If it ## is omitted, 64 is assumed. ## at end deftypefn ## Author: Tony Richardson ## Created: July 1994 ## Adapted-By: jwe ## Adapted-By: Felipe Bertrand function map = hot (number) if (nargin == 0) number = 64; elseif (nargin == 1) if (! is_scalar (number)) error ("hot: argument must be a scalar"); end else usage ("hot (number)"); end onethird = ceil(number/3); twothirds = ceil(2*number/3); dr = 1 / (onethird-1); r = postpad([0:dr:1],number,1)'; dg = 1 / (twothirds-onethird); g= postpad(prepad([0:dg:1],twothirds,0),number,1)'; db = 1 / (number-twothirds); b = prepad([0:db:1],number,0)'; map = [ r, g, b ]; endfunction --bp/iNruPH9dso1Pn--