1## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2005,
2## 2006, 2007, 2009 John W. Eaton
4## This file is part of Octave.
6## Octave is free software; you can redistribute it and/or modify it
7## under the terms of the GNU General Public License as published by
8## the Free Software Foundation; either version 3 of the License, or (at
9## your option) any later version.
11## Octave is distributed in the hope that it will be useful, but
12## WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14## General Public License for more details.
16## You should have received a copy of the GNU General Public License
17## along with Octave; see the file COPYING. If not, see
18## <http://www.gnu.org/licenses/>.
21## @deftypefn {Function File} {} colormap (@var{map})
22## @deftypefnx {Function File} {} colormap ("default")
23## Set the current colormap.
25## @code{colormap (@var{map})} sets the current colormap to @var{map}. The
26## color map should be an @var{n} row by 3 column matrix. The columns
27## contain red, green, and blue intensities respectively. All entries
28## should be between 0 and 1 inclusive. The new colormap is returned.
30## @code{colormap ("default")} restores the default colormap (the
31## @code{jet} map with 64 entries). The default colormap is returned.
33## With no arguments, @code{colormap} returns the current color map.
37## Author: Tony Richardson <arichard@stark.cc.oh.us>
41function cmap = colormap (map)
50 if (strcmp (map, "default"))
58 if (columns (map) != 3)
59 error ("colormap: map must have 3 columns: [R,G,B]");
61 if (min (min (map)) < 0 || max (max (map)) > 1)
62 error ("colormap: map must have values in [0,1]");
64 ## Set the new color map
65 set (gcf (), "colormap", map);
70 ## Return current color map.
71 if (nargout > 0 || (nargout == 0 && nargin == 0))
72 cmap = get (gcf (), "colormap");