annotate scripts/image/colormap.m @ 30329:81d26e8481a6

maint: Shorten @seealso lines to less than 80 characters (bug #57599) * chol.cc, data.cc, debug.cc, file-io.cc, load-save.cc, oct-hist.cc, pr-output.cc, sparse.cc, syscalls.cc, time.cc, utils.cc, ov-struct.cc, base64decode.m, base64encode.m, getappdata.m, isappdata.m, setappdata.m, colormap.m, isdir.m, cast.m, getfield.m, isfile.m, isfolder.m, setfield.m, contour.m, contour3.m, contourf.m, ezplot.m, isosurface.m, mesh.m, meshc.m, meshz.m, plot.m, surf.m, surfc.m, waterfall.m, movmad.m, movmax.m, movmean.m, movmedian.m, movmin.m, movprod.m, movstd.m, movsum.m, movvar.m: Shorten @seealso lines to less than 80 characters.
author Rik <rik@octave.org>
date Tue, 23 Nov 2021 11:26:38 -0800
parents 7854d5752dd2
children 212461a26e9c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27985
diff changeset
3 ## Copyright (C) 1994-2021 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
7 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
8 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22636
diff changeset
13 ## (at your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22636
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22636
diff changeset
18 ## GNU General Public License for more details.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
19 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
20 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24220
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
1024
56520a75b5b3 [project @ 1995-01-11 20:30:04 by jwe]
jwe
parents: 904
diff changeset
25
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3373
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20532
diff changeset
27 ## @deftypefn {} {@var{cmap} =} colormap ()
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20532
diff changeset
28 ## @deftypefnx {} {@var{cmap} =} colormap (@var{map})
21973
894239974868 colormap: remove functionality to list and register colormaps (bug #48272)
Carnë Draug <carandraug@octave.org>
parents: 21758
diff changeset
29 ## @deftypefnx {} {@var{cmap} =} colormap (@qcode{"default"})
894239974868 colormap: remove functionality to list and register colormaps (bug #48272)
Carnë Draug <carandraug@octave.org>
parents: 21758
diff changeset
30 ## @deftypefnx {} {@var{cmap} =} colormap (@var{map_name})
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20532
diff changeset
31 ## @deftypefnx {} {@var{cmap} =} colormap (@var{hax}, @dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20532
diff changeset
32 ## @deftypefnx {} {} colormap @var{map_name}
14260
1f911333ed3d doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents: 14246
diff changeset
33 ## Query or set the current colormap.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3381
diff changeset
34 ##
16946
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
35 ## With no input arguments, @code{colormap} returns the current color map.
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
36 ##
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3238
diff changeset
37 ## @code{colormap (@var{map})} sets the current colormap to @var{map}. The
14260
1f911333ed3d doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents: 14246
diff changeset
38 ## colormap should be an @var{n} row by 3 column matrix. The columns
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3238
diff changeset
39 ## contain red, green, and blue intensities respectively. All entries
14260
1f911333ed3d doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents: 14246
diff changeset
40 ## must be between 0 and 1 inclusive. The new colormap is returned.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3381
diff changeset
41 ##
21973
894239974868 colormap: remove functionality to list and register colormaps (bug #48272)
Carnë Draug <carandraug@octave.org>
parents: 21758
diff changeset
42 ## @code{colormap (@qcode{"default"})} restores the default colormap (the
20532
2480bbcd1333 fix documentation for new viridis colormap
John W. Eaton <jwe@octave.org>
parents: 20530
diff changeset
43 ## @code{viridis} map with 64 entries). The default colormap is returned.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3381
diff changeset
44 ##
21973
894239974868 colormap: remove functionality to list and register colormaps (bug #48272)
Carnë Draug <carandraug@octave.org>
parents: 21758
diff changeset
45 ## The map may also be specified by a string, @var{map_name}, which
894239974868 colormap: remove functionality to list and register colormaps (bug #48272)
Carnë Draug <carandraug@octave.org>
parents: 21758
diff changeset
46 ## is the name of a function that returns a colormap.
17305
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
47 ##
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
48 ## If the first argument @var{hax} is an axes handle, then the colormap for
23524
7c278572db66 Implement colormap property for axes objects (bug #48667).
Markus Muetzel <markus.muetzel@gmx.de>
parents: 23220
diff changeset
49 ## those axes is queried or set.
14640
b9c02ee24de1 new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents: 14260
diff changeset
50 ##
16947
24bb7dc754ed Document command form of colormap().
Carnë Draug <carandraug@octave.org>
parents: 16946
diff changeset
51 ## For convenience, it is also possible to use this function with the
17305
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
52 ## command form, @code{colormap @var{map_name}}.
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
53 ##
22628
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
54 ## The list of built-in colormaps is:
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
55 ##
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
56 ## @c FIXME: It would be nice to display the actual colormap as an image
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
57 ## @c in the PDF version of the documentation.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
58 ## @multitable @columnfractions 0.15 .85
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
59 ## @headitem Map @tab Description
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
60 ## @item viridis @tab default
29348
fe21f065fc23 turbo.m: New colormap file (bug #59998).
Christian Himpe <christian.himpe@wwu.de>
parents: 28912
diff changeset
61 ## @item turbo @tab colormap traversing blue, cyan, green, yellow, red; modern replacement for jet.
22628
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
62 ## @item jet @tab colormap traversing blue, cyan, green, yellow, red.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
63 ## @item cubehelix @tab colormap traversing black, blue, green, red, white with increasing intensity.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
64 ## @item hsv @tab cyclic colormap traversing Hue, Saturation, Value space.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
65 ## @item rainbow @tab colormap traversing red, yellow, blue, green, violet.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
66 ## @item ------------- @tab ---------------------------------------------------------------------------------------------
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
67 ## @item hot @tab colormap traversing black, red, orange, yellow, white.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
68 ## @item cool @tab colormap traversing cyan, purple, magenta.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
69 ## @item spring @tab colormap traversing magenta to yellow.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
70 ## @item summer @tab colormap traversing green to yellow.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
71 ## @item autumn @tab colormap traversing red, orange, yellow.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
72 ## @item winter @tab colormap traversing blue to green.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
73 ## @item ------------- @tab ---------------------------------------------------------------------------------------------
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
74 ## @item gray @tab colormap traversing black to white in shades of gray.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
75 ## @item bone @tab colormap traversing black, gray-blue, white.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
76 ## @item copper @tab colormap traversing black to light copper.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
77 ## @item pink @tab colormap traversing black, gray-pink, white.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
78 ## @item ocean @tab colormap traversing black, dark-blue, white.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
79 ## @item ------------- @tab ---------------------------------------------------------------------------------------------
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
80 ## @item colorcube @tab equally spaced colors in RGB color space.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
81 ## @item flag @tab cyclic 4-color map of red, white, blue, black.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
82 ## @item lines @tab cyclic colormap with colors from axes @qcode{"ColorOrder"} property.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
83 ## @item prism @tab cyclic 6-color map of red, orange, yellow, green, blue, violet.
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
84 ## @item ------------- @tab ---------------------------------------------------------------------------------------------
a918e983a943 doc: Add list of built-in colormaps to colormap documentation (bug #49363).
Rik <rik@octave.org>
parents: 22543
diff changeset
85 ## @item white @tab all white colormap (no colors).
22636
c44d57c0a925 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22628
diff changeset
86 ## @end multitable
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29359
diff changeset
87 ## @seealso{viridis, turbo, jet, cubehelix, hsv, rainbow, hot, cool, spring,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29359
diff changeset
88 ## summer, autumn, winter, gray, bone, copper, pink, ocean, colorcube, flag, lines, prism, white}
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3238
diff changeset
89 ## @end deftypefn
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
90
17305
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
91 function cmap = colormap (varargin)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
92
17305
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
93 [hax, varargin, nargin] = __plt_get_axis_arg__ ("colormap", varargin{:});
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
94
21973
894239974868 colormap: remove functionality to list and register colormaps (bug #48272)
Carnë Draug <carandraug@octave.org>
parents: 21758
diff changeset
95 if (nargin > 1)
5923
611e30b984b3 [project @ 2006-08-14 18:29:18 by jwe]
jwe
parents: 5443
diff changeset
96 print_usage ();
1062
1b3a87031641 [project @ 1995-01-24 02:54:50 by jwe]
jwe
parents: 1024
diff changeset
97 endif
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
98
17305
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
99 if (! isempty (hax))
23524
7c278572db66 Implement colormap property for axes objects (bug #48667).
Markus Muetzel <markus.muetzel@gmx.de>
parents: 23220
diff changeset
100 cf = hax;
17305
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
101 else
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
102 cf = get (0, "currentfigure");
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
103 endif
14640
b9c02ee24de1 new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents: 14260
diff changeset
104
1024
56520a75b5b3 [project @ 1995-01-11 20:30:04 by jwe]
jwe
parents: 904
diff changeset
105 if (nargin == 1)
24220
2b7532f237d7 colormap.m: fix regression introduced with 547919e6aec1
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24204
diff changeset
106 map = varargin{1};
5443
ec8c33dcd1bf [project @ 2005-09-08 01:40:57 by jwe]
jwe
parents: 5307
diff changeset
107 if (ischar (map))
24220
2b7532f237d7 colormap.m: fix regression introduced with 547919e6aec1
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 24204
diff changeset
108 map = tolower (map);
1024
56520a75b5b3 [project @ 1995-01-11 20:30:04 by jwe]
jwe
parents: 904
diff changeset
109 if (strcmp (map, "default"))
20532
2480bbcd1333 fix documentation for new viridis colormap
John W. Eaton <jwe@octave.org>
parents: 20530
diff changeset
110 map = viridis (64);
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
111 else
22543
b9f5ac691e03 colormap.m: Emit clearer error when map name does not exist (bug #49202).
Rik <rik@octave.org>
parents: 22323
diff changeset
112 try
b9f5ac691e03 colormap.m: Emit clearer error when map name does not exist (bug #49202).
Rik <rik@octave.org>
parents: 22323
diff changeset
113 map = feval (map);
b9f5ac691e03 colormap.m: Emit clearer error when map name does not exist (bug #49202).
Rik <rik@octave.org>
parents: 22323
diff changeset
114 catch
b9f5ac691e03 colormap.m: Emit clearer error when map name does not exist (bug #49202).
Rik <rik@octave.org>
parents: 22323
diff changeset
115 error ("colormap: failed to set MAP <%s>", map);
b9f5ac691e03 colormap.m: Emit clearer error when map name does not exist (bug #49202).
Rik <rik@octave.org>
parents: 22323
diff changeset
116 end_try_catch
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
117 endif
3238
041ea33fbbf4 [project @ 1999-03-26 17:48:16 by jwe]
jwe
parents: 3202
diff changeset
118 endif
041ea33fbbf4 [project @ 1999-03-26 17:48:16 by jwe]
jwe
parents: 3202
diff changeset
119
041ea33fbbf4 [project @ 1999-03-26 17:48:16 by jwe]
jwe
parents: 3202
diff changeset
120 if (! isempty (map))
15714
b1cd65881592 Clean up scripts in image directory.
Rik <rik@octave.org>
parents: 15683
diff changeset
121 if (! (isnumeric (map) && isreal (map)
b1cd65881592 Clean up scripts in image directory.
Rik <rik@octave.org>
parents: 15683
diff changeset
122 && ndims (map) == 2 && columns (map) == 3))
b1cd65881592 Clean up scripts in image directory.
Rik <rik@octave.org>
parents: 15683
diff changeset
123 error ("colormap: MAP must be a real-valued N x 3 ([R,G,B]) matrix");
3238
041ea33fbbf4 [project @ 1999-03-26 17:48:16 by jwe]
jwe
parents: 3202
diff changeset
124 endif
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 14640
diff changeset
125 if (any (map(:) < 0) || any (map(:) > 1))
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 14640
diff changeset
126 error ("colormap: all MAP values must be in the range [0,1]");
3238
041ea33fbbf4 [project @ 1999-03-26 17:48:16 by jwe]
jwe
parents: 3202
diff changeset
127 endif
17305
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
128 if (isempty (cf))
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
129 cf = gcf ();
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
130 endif
2303
5cffc4b8de57 [project @ 1996-06-24 09:15:24 by jwe]
jwe
parents: 1887
diff changeset
131 ## Set the new color map
17305
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
132 set (cf, "colormap", map);
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
133 endif
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
134 endif
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
135
2303
5cffc4b8de57 [project @ 1996-06-24 09:15:24 by jwe]
jwe
parents: 1887
diff changeset
136 ## Return current color map.
21973
894239974868 colormap: remove functionality to list and register colormaps (bug #48272)
Carnë Draug <carandraug@octave.org>
parents: 21758
diff changeset
137 if (nargout > 0 || nargin == 0)
17305
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
138 if (isempty (cf))
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
139 cf = gcf ();
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
140 endif
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
141 cmap = get (cf, "colormap");
6762
721953d49b19 [project @ 2007-06-27 18:20:19 by jwe]
jwe
parents: 6257
diff changeset
142 endif
1024
56520a75b5b3 [project @ 1995-01-11 20:30:04 by jwe]
jwe
parents: 904
diff changeset
143
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
144 endfunction
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 14640
diff changeset
145
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 14640
diff changeset
146
16946
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
147 %!demo
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
148 %! ## Create an image for displaying a colormap
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
149 %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
150 %! axis ([1, 64, 0, 1], "ticy", "xy");
20532
2480bbcd1333 fix documentation for new viridis colormap
John W. Eaton <jwe@octave.org>
parents: 20530
diff changeset
151 %! ## Show 'viridis' colormap
2480bbcd1333 fix documentation for new viridis colormap
John W. Eaton <jwe@octave.org>
parents: 20530
diff changeset
152 %! colormap (viridis (64));
2480bbcd1333 fix documentation for new viridis colormap
John W. Eaton <jwe@octave.org>
parents: 20530
diff changeset
153 %! title "colormap (viridis (64))"
16946
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
154 %! disp ("Press a key to continue");
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
155 %! pause ();
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
156 %! ## Show 'colorcube' colormap
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
157 %! colormap (colorcube (64));
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
158 %! title "colormap (colorcube (64))"
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
159
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
160 %!test
17305
ab71b9829752 colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents: 17281
diff changeset
161 %! hf = figure ("visible", "off");
19667
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
162 %! unwind_protect
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
163 %! cmaptst = [0 1 0; 1 0 1; 1 1 1];
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
164 %! cmap = colormap (cmaptst);
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
165 %! assert (cmap, cmaptst);
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
166 %! cmap = colormap ();
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
167 %! assert (cmap, cmaptst);
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
168 %! cmap = (get (gcf, "colormap"));
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
169 %! assert (cmap, cmaptst);
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
170 %! colormap ("default");
20532
2480bbcd1333 fix documentation for new viridis colormap
John W. Eaton <jwe@octave.org>
parents: 20530
diff changeset
171 %! assert (colormap (), viridis (64));
19667
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
172 %! colormap ("ocean");
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
173 %! assert (colormap, ocean (64));
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
174 %! unwind_protect_cleanup
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
175 %! close (hf);
4b1a43786489 colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents: 19610
diff changeset
176 %! end_unwind_protect
16946
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
177
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
178 ## Test input validation
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
179 %!error colormap (1,2,3)
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
180 %!error <MAP must be a real-valued N x 3> colormap ({1,2,3})
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
181 %!error <MAP must be a real-valued N x 3> colormap ([1 i 1])
28912
0de38a6ef693 maint: Use Octave convention of space after function name in scripts dir.
Rik <rik@octave.org>
parents: 27985
diff changeset
182 %!error <MAP must be a real-valued N x 3> colormap (ones (3,3,3))
16946
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
183 %!error <MAP must be a real-valued N x 3> colormap ([1 0 1 0])
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
184 %!error <all MAP values must be in the range> colormap ([-1 0 0])
92f42d9f2ae4 colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents: 16766
diff changeset
185 %!error <all MAP values must be in the range> colormap ([2 0 0])
22543
b9f5ac691e03 colormap.m: Emit clearer error when map name does not exist (bug #49202).
Rik <rik@octave.org>
parents: 22323
diff changeset
186 %!error <failed to set MAP .invalid_map_name.> colormap ("invalid_map_name")