changelog shortlog tags changeset files revisions annotate raw

scripts/image/gmap40.m

changeset 10289: 4b124317dc38
parent:16f53d29049f
author: John W. Eaton <jwe@octave.org>
date: Tue Feb 09 20:58:55 2010 -0500 (44 minutes ago)
permissions: -rw-r--r--
description: base_properties::set_children: account for hidden children
1## Copyright (C) 2007, 2008, 2009 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} {} gmap40 (@var{n})
21## Create a color colormap. The colormap is red, green, blue, yellow,
22## magenta and cyan. These are the colors that are allowed with patch
23## objects using gnuplot 4.0, and so this colormap function is specially
24## designed for users of gnuplot 4.0. The argument @var{n} should be
25## a scalar. If it is omitted, a length of 6 is assumed. Larger values
26## of @var{n} result in a repetition of the above colors
27## @seealso{colormap}
28## @end deftypefn
29
30function map = gmap40 (number)
31
32 if (nargin == 0)
33 number = 6;
34 elseif (nargin == 1)
35 if (! isscalar (number))
36 error ("gmap40: argument must be a scalar");
37 endif
38 else
39 print_usage ();
40 endif
41
42 if (number >= 1)
43 map = repmat ([1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1],
44 ceil (number / 6), 1) (1:number, :);
45 else
46 map = [];
47 endif
48
49endfunction
50
51%!demo
52%! ## Show the 'gmap40' colormap as an image
53%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
54%! axis ([1, 64, 0, 1], "ticy", "xy")
55%! colormap gmap40
56