]> Creatis software - CreaPhase.git/blob - octave_packages/m/image/gmap40.m
update packages
[CreaPhase.git] / octave_packages / m / image / gmap40.m
1 ## Copyright (C) 2007-2012 David Bateman
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING.  If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn  {Function File} {@var{map} =} gmap40 ()
21 ## @deftypefnx {Function File} {@var{map} =} gmap40 (@var{n})
22 ## Create color colormap.  The colormap consists of red, green, blue, yellow,
23 ## magenta and cyan.  This colormap is specifically designed for users of
24 ## gnuplot 4.0 where these 6 colors are the allowable ones for patch objects.
25 ## The argument @var{n} must be a scalar.
26 ## If unspecified, a length of 6 is assumed.  Larger values
27 ## of @var{n} result in a repetition of the above colors.
28 ## @seealso{colormap}
29 ## @end deftypefn
30
31 function map = gmap40 (n)
32
33   if (nargin == 0)
34     n = 6;
35   elseif (nargin == 1)
36     if (! isscalar (n))
37       error ("gmap40: argument must be a scalar");
38     endif
39   else
40     print_usage ();
41   endif
42
43   if (n >= 1)
44     map = repmat ([1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1],
45           ceil (n / 6), 1) (1:n, :);
46   else
47     map = [];
48   endif
49
50 endfunction
51
52 %!demo
53 %! ## Show the 'gmap40' colormap as an image
54 %! image (1:6, linspace (0, 1, 6), repmat (1:6, 6, 1)')
55 %! axis ([1, 6, 0, 1], "ticy", "xy")
56 %! colormap (gmap40 (6))
57