7189
|
1 ## Copyright (C) 2007 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} {} caxis (@var{limits}) |
|
21 ## @deftypefnx {Function File} {} caxis (@var{h}, @dots{}) |
|
22 ## Set color axis limits for plots. |
|
23 ## |
|
24 ## The argument @var{limits} should be a 2 element vector specifying the |
|
25 ## lower and upper limits to assign to the first and last value in the |
|
26 ## colormap. Values outside this range are clamped to the first and last |
|
27 ## colormap entries. |
|
28 ## |
|
29 ## If @var{limits} is 'auto', then automatic colormap scaling is applied, |
|
30 ## whereas if @var{limits} is 'manual' the colormap scaling is set to manual. |
|
31 ## |
|
32 ## Called without any arguments to current color axis limits are returned. |
|
33 ## |
|
34 ## If an axes handle is passed as the first argument, then operate on |
|
35 ## this axes rather than the current axes. |
|
36 ## @end deftypefn |
|
37 |
|
38 ## PKG_ADD: mark_as_command caxis |
|
39 |
|
40 function varargout = caxis (varargin) |
|
41 |
7215
|
42 [h, varargin, nargin] = __plt_get_axis_arg__ ("caxis", varargin{:}); |
|
43 oldh = gca (); |
|
44 unwind_protect |
|
45 axes (h); |
7189
|
46 varargout = cell (max (nargin == 0, nargout), 1); |
|
47 if (isempty (varargout)) |
7215
|
48 __caxis__ (h, varargin{:}); |
7189
|
49 else |
7215
|
50 [varargout{:}] = __caxis__ (h, varargin{:}); |
7189
|
51 endif |
7215
|
52 unwind_protect_cleanup |
|
53 axes (oldh); |
|
54 end_unwind_protect |
7189
|
55 |
|
56 endfunction |
|
57 |
|
58 function [cmin, cmax] = __caxis__ (ca, ax, varargin) |
|
59 |
|
60 if (nargin == 1) |
|
61 cmin = get (ca, "clim"); |
|
62 if (nargout > 1) |
|
63 cmax = cmin(2); |
|
64 cmin = cmin(1); |
|
65 endif |
|
66 elseif (ischar (ax)) |
|
67 ax = tolower (ax); |
|
68 if (strcmp (ax, "auto")) |
|
69 set (ca, "climmode", "auto"); |
|
70 elseif (strcmp (ax, "manual")) |
|
71 set (ca, "climmode", "manual"); |
|
72 endif |
|
73 elseif (isvector (ax)) |
|
74 len = length (ax); |
|
75 |
|
76 if (len != 2) |
|
77 error ("caxis: expecting vector with 2 elements"); |
|
78 endif |
|
79 |
|
80 set (ca, "clim", [ax(1), ax(2)]); |
|
81 else |
|
82 error ("caxis: expecting no args, a string or a 2 element vector"); |
|
83 endif |
|
84 |
|
85 if (nargin > 2) |
|
86 __caxis__ (ca, varargin{:})' |
|
87 endif |
|
88 |
|
89 endfunction |
|
90 |