1## Copyright (C) 2007, 2008, 2009 David Bateman
3## This file is part of Octave.
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.
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.
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/>.
20## @deftypefn {Function File} {} caxis (@var{limits})
21## @deftypefnx {Function File} {} caxis (@var{h}, @dots{})
22## Set color axis limits for plots.
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
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.
32## Called without any arguments to current color axis limits are returned.
34## If an axes handle is passed as the first argument, then operate on
35## this axes rather than the current axes.
38function varargout = caxis (varargin)
40 [h, varargin, nargin] = __plt_get_axis_arg__ ("caxis", varargin{:});
45 varargout = cell (max (nargin == 0, nargout), 1);
46 if (isempty (varargout))
47 __caxis__ (h, varargin{:});
49 [varargout{:}] = __caxis__ (h, varargin{:});
51 unwind_protect_cleanup
57function [cmin, cmax] = __caxis__ (ca, ax, varargin)
60 cmin = get (ca, "clim");
66 if (strcmpi (ax, "auto"))
67 set (ca, "climmode", "auto");
68 elseif (strcmpi (ax, "manual"))
69 set (ca, "climmode", "manual");
71 elseif (isvector (ax))
75 error ("caxis: expecting vector with 2 elements");
78 set (ca, "clim", [ax(1), ax(2)]);
80 error ("caxis: expecting no args, a string or a 2 element vector");
84 __caxis__ (ca, varargin{:})'