Mercurial > octave
annotate scripts/image/colormap.m @ 31191:bb9d776eafac stable
Fix wrong color in PDF printout of some latex strings (bug #62884)
* octave-svgconvert (draw): For "rect" elements only set brush color if
necessary and eventually restore to previous color.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Sun, 14 Aug 2022 18:24:07 +0200 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
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 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30353
diff
changeset
|
3 ## Copyright (C) 1994-2022 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 | 7 ## |
8 ## This file is part of Octave. | |
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 | 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 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
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 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 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 | 25 |
3381 | 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 | 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 | 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 | 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 | 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 | 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, |
30353
212461a26e9c
doc: grammarcheck m-files in scripts/ directory ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30329
diff
changeset
|
88 ## summer, autumn, winter, gray, bone, copper, pink, ocean, colorcube, flag, |
212461a26e9c
doc: grammarcheck m-files in scripts/ directory ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30329
diff
changeset
|
89 ## lines, prism, white} |
3373 | 90 ## @end deftypefn |
559 | 91 |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
92 function cmap = colormap (varargin) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
93 |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
94 [hax, varargin, nargin] = __plt_get_axis_arg__ ("colormap", varargin{:}); |
559 | 95 |
21973
894239974868
colormap: remove functionality to list and register colormaps (bug #48272)
Carnë Draug <carandraug@octave.org>
parents:
21758
diff
changeset
|
96 if (nargin > 1) |
5923 | 97 print_usage (); |
1062 | 98 endif |
559 | 99 |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
100 if (! isempty (hax)) |
23524
7c278572db66
Implement colormap property for axes objects (bug #48667).
Markus Muetzel <markus.muetzel@gmx.de>
parents:
23220
diff
changeset
|
101 cf = hax; |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
102 else |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
103 cf = get (0, "currentfigure"); |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
104 endif |
14640
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
105 |
1024 | 106 if (nargin == 1) |
24220
2b7532f237d7
colormap.m: fix regression introduced with 547919e6aec1
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24204
diff
changeset
|
107 map = varargin{1}; |
5443 | 108 if (ischar (map)) |
24220
2b7532f237d7
colormap.m: fix regression introduced with 547919e6aec1
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24204
diff
changeset
|
109 map = tolower (map); |
1024 | 110 if (strcmp (map, "default")) |
20532
2480bbcd1333
fix documentation for new viridis colormap
John W. Eaton <jwe@octave.org>
parents:
20530
diff
changeset
|
111 map = viridis (64); |
559 | 112 else |
22543
b9f5ac691e03
colormap.m: Emit clearer error when map name does not exist (bug #49202).
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
113 try |
b9f5ac691e03
colormap.m: Emit clearer error when map name does not exist (bug #49202).
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
114 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
|
115 catch |
b9f5ac691e03
colormap.m: Emit clearer error when map name does not exist (bug #49202).
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
116 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
|
117 end_try_catch |
559 | 118 endif |
3238 | 119 endif |
120 | |
121 if (! isempty (map)) | |
15714
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15683
diff
changeset
|
122 if (! (isnumeric (map) && isreal (map) |
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15683
diff
changeset
|
123 && ndims (map) == 2 && columns (map) == 3)) |
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15683
diff
changeset
|
124 error ("colormap: MAP must be a real-valued N x 3 ([R,G,B]) matrix"); |
3238 | 125 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
|
126 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
|
127 error ("colormap: all MAP values must be in the range [0,1]"); |
3238 | 128 endif |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
129 if (isempty (cf)) |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
130 cf = gcf (); |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
131 endif |
2303 | 132 ## Set the new color map |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
133 set (cf, "colormap", map); |
559 | 134 endif |
135 endif | |
136 | |
2303 | 137 ## 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
|
138 if (nargout > 0 || nargin == 0) |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
139 if (isempty (cf)) |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
140 cf = gcf (); |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
141 endif |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
142 cmap = get (cf, "colormap"); |
6762 | 143 endif |
1024 | 144 |
559 | 145 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
|
146 |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14640
diff
changeset
|
147 |
16946
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
148 %!demo |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
149 %! ## 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
|
150 %! 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
|
151 %! 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
|
152 %! ## Show 'viridis' colormap |
2480bbcd1333
fix documentation for new viridis colormap
John W. Eaton <jwe@octave.org>
parents:
20530
diff
changeset
|
153 %! colormap (viridis (64)); |
2480bbcd1333
fix documentation for new viridis colormap
John W. Eaton <jwe@octave.org>
parents:
20530
diff
changeset
|
154 %! 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
|
155 %! 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
|
156 %! pause (); |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
157 %! ## Show 'colorcube' colormap |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
158 %! colormap (colorcube (64)); |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
159 %! title "colormap (colorcube (64))" |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
160 |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
161 %!test |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
162 %! 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
|
163 %! unwind_protect |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
164 %! 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
|
165 %! cmap = colormap (cmaptst); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
166 %! assert (cmap, cmaptst); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
167 %! cmap = colormap (); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
168 %! assert (cmap, cmaptst); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
169 %! cmap = (get (gcf, "colormap")); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
170 %! assert (cmap, cmaptst); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
171 %! colormap ("default"); |
20532
2480bbcd1333
fix documentation for new viridis colormap
John W. Eaton <jwe@octave.org>
parents:
20530
diff
changeset
|
172 %! 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
|
173 %! colormap ("ocean"); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
174 %! assert (colormap, ocean (64)); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
175 %! unwind_protect_cleanup |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
176 %! close (hf); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
177 %! end_unwind_protect |
16946
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
178 |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
179 ## Test input validation |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
180 %!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
|
181 %!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
|
182 %!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
|
183 %!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
|
184 %!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
|
185 %!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
|
186 %!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
|
187 %!error <failed to set MAP .invalid_map_name.> colormap ("invalid_map_name") |