annotate scripts/plot/appearance/caxis.m @ 23084:ef4d915df748

maint: Merge stable to default.
author John W. Eaton <jwe@octave.org>
date Mon, 23 Jan 2017 14:27:48 -0500
parents 3918beb3edc6 e9a0469dedd9
children 092078913d54
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 20852
diff changeset
1 ## Copyright (C) 2007-2016 David Bateman
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
2 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
3 ## This file is part of Octave.
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
4 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
8 ## (at your option) any later version.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
9 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## GNU General Public License for more details.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
14 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
18
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20711
diff changeset
20 ## @deftypefn {} {} caxis ([cmin cmax])
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20711
diff changeset
21 ## @deftypefnx {} {} caxis ("auto")
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20711
diff changeset
22 ## @deftypefnx {} {} caxis ("manual")
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20711
diff changeset
23 ## @deftypefnx {} {} caxis (@var{hax}, @dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20711
diff changeset
24 ## @deftypefnx {} {@var{limits} =} caxis ()
17062
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
25 ## Query or set color axis limits for plots.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
26 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
27 ## The limits argument should be a 2-element vector specifying the lower and
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
28 ## upper limits to assign to the first and last value in the colormap. Data
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
29 ## values outside this range are clamped to the first and last colormap
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
30 ## entries.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
31 ##
17442
4e86bb1901d6 caxis.m: Add more information to docstring.
Rik <rik@octave.org>
parents: 17301
diff changeset
32 ## If the @qcode{"auto"} option is given then automatic colormap limits are
4e86bb1901d6 caxis.m: Add more information to docstring.
Rik <rik@octave.org>
parents: 17301
diff changeset
33 ## applied. The automatic algorithm sets @var{cmin} to the minimum data value
4e86bb1901d6 caxis.m: Add more information to docstring.
Rik <rik@octave.org>
parents: 17301
diff changeset
34 ## and @var{cmax} to the maximum data value. If @qcode{"manual"} is specified
4e86bb1901d6 caxis.m: Add more information to docstring.
Rik <rik@octave.org>
parents: 17301
diff changeset
35 ## then the @qcode{"climmode"} property is set to @qcode{"manual"} and the
4e86bb1901d6 caxis.m: Add more information to docstring.
Rik <rik@octave.org>
parents: 17301
diff changeset
36 ## numeric values in the @qcode{"clim"} property are used for limits.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
37 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17062
diff changeset
38 ## If the first argument @var{hax} is an axes handle, then operate on
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17062
diff changeset
39 ## this axis rather than the current axes returned by @code{gca}.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
40 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17062
diff changeset
41 ## Called without arguments the current color axis limits are returned.
22817
9cb15c322464 doc: Add programming note to caxis docstring.
Rik <rik@octave.org>
parents: 22323
diff changeset
42 ##
9cb15c322464 doc: Add programming note to caxis docstring.
Rik <rik@octave.org>
parents: 22323
diff changeset
43 ## Programming Note: The color axis affects the display of image, patch, and
9cb15c322464 doc: Add programming note to caxis docstring.
Rik <rik@octave.org>
parents: 22323
diff changeset
44 ## surface graphics objects, but @strong{only} if the @qcode{"cdata"} property
9cb15c322464 doc: Add programming note to caxis docstring.
Rik <rik@octave.org>
parents: 22323
diff changeset
45 ## has indexed data and the @qcode{"cdatamapping"} property is set to
9cb15c322464 doc: Add programming note to caxis docstring.
Rik <rik@octave.org>
parents: 22323
diff changeset
46 ## @qcode{"scaled"}. Graphic objects with true color @code{cdata}, or
9cb15c322464 doc: Add programming note to caxis docstring.
Rik <rik@octave.org>
parents: 22323
diff changeset
47 ## @qcode{"direct"} @code{cdatamapping} are not affected.
9cb15c322464 doc: Add programming note to caxis docstring.
Rik <rik@octave.org>
parents: 22323
diff changeset
48 ## @seealso{colormap, axis}
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
49 ## @end deftypefn
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
50
17062
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
51 function limits = caxis (varargin)
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
52
17062
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
53 [hax, varargin, nargin] = __plt_get_axis_arg__ ("caxis", varargin{:});
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
54
17211
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17122
diff changeset
55 oldfig = [];
17301
68bcac3c043a Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents: 17281
diff changeset
56 if (! isempty (hax))
17211
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17122
diff changeset
57 oldfig = get (0, "currentfigure");
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17122
diff changeset
58 endif
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7189
diff changeset
59 unwind_protect
17062
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
60 if (isempty (hax))
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
61 hax = gca ();
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
62 endif
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
63 if (nargin == 0)
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
64 limits = __caxis__ (hax);
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
65 else
17062
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
66 __caxis__ (hax, varargin{:});
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
67 endif
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7189
diff changeset
68 unwind_protect_cleanup
17062
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
69 if (! isempty (oldfig))
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
70 set (0, "currentfigure", oldfig);
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
71 endif
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7189
diff changeset
72 end_unwind_protect
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
73
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
74 endfunction
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
75
17062
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
76 function limits = __caxis__ (ca, ax, varargin)
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
77
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
78 if (nargin == 1)
17062
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
79 limits = get (ca, "clim");
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
80 elseif (ischar (ax))
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7216
diff changeset
81 if (strcmpi (ax, "auto"))
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
82 set (ca, "climmode", "auto");
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7216
diff changeset
83 elseif (strcmpi (ax, "manual"))
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
84 set (ca, "climmode", "manual");
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
85 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
86 elseif (isvector (ax))
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
87 len = length (ax);
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
88 if (len != 2)
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20173
diff changeset
89 error ("caxis: LIMITS must be a 2-element vector");
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
90 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
91
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
92 set (ca, "clim", [ax(1), ax(2)]);
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
93 else
17062
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
94 error ("caxis: expecting no args, a string, or a 2 element vector");
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
95 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
96
17062
19c3b5bf5c8e caxis.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14359
diff changeset
97 ## FIXME: Why should it be possible to call __caxis__ recursively?
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
98 if (nargin > 2)
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
99 __caxis__ (ca, varargin{:})';
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
100 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
101
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
102 endfunction