1 ## Copyright (C) 1994-2012 John W. Eaton
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} {} imagesc (@var{A})
21 ## @deftypefnx {Function File} {} imagesc (@var{x}, @var{y}, @var{A})
22 ## @deftypefnx {Function File} {} imagesc (@dots{}, @var{limits})
23 ## @deftypefnx {Function File} {} imagesc (@var{h}, @dots{})
24 ## @deftypefnx {Function File} {@var{h} =} imagesc (@dots{})
25 ## Display a scaled version of the matrix @var{A} as a color image. The
26 ## colormap is scaled so that the entries of the matrix occupy the entire
27 ## colormap. If @var{limits} = [@var{lo}, @var{hi}] are given, then that
28 ## range is set to the 'clim' of the current axes.
30 ## The axis values corresponding to the matrix elements are specified in
31 ## @var{x} and @var{y}, either as pairs giving the minimum and maximum
32 ## values for the respective axes, or as values for each row and column
33 ## of the matrix @var{A}.
35 ## The optional return value @var{h} is a graphics handle to the image.
36 ## @seealso{image, imshow, caxis}
39 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
43 function retval = imagesc (varargin)
47 elseif (isscalar (varargin{1}) && ishandle (varargin{1}))
49 if (! strcmp (get (h, "type"), "axes"))
50 error ("imagesc: expecting first argument to be an axes object");
55 tmp = __imagesc__ (h, varargin{2:end});
56 unwind_protect_cleanup
60 tmp = __imagesc__ (gca (), varargin{:});
69 function ret = __imagesc__ (ax, x, y, A, limits, DEPRECATEDZOOM)
71 ## Deprecated zoom. Remove this hunk of code if old zoom argument
73 if ((nargin == 3 && isscalar (y))
74 || (nargin == 4 && (isscalar (y) || isscalar (A)))
75 || (nargin == 5 && isscalar (limits))
77 warning ("image: zoom argument ignored -- use GUI features");
80 if (isscalar (limits))
81 limits = DEPRECATEDZOOM;
85 if (nargin == 5 && isscalar (limits))
88 if (nargin == 4 && (isscalar (y) || isscalar (A)))
94 if (nargin == 3 && isscalar (y))
98 if (nargin < 2 || nargin > 5)
107 elseif (nargin == 4 && ! isscalar (x) && ! isscalar (y) && ! isscalar (A))
111 ret = image (ax, x, y, A);
112 set (ret, "cdatamapping", "scaled");
114 ## use given limits or guess them from the matrix
115 if (length (limits) == 2 && limits(2) >= limits(1))
116 set (ax, "clim", limits);
117 elseif (! isempty (limits))
118 error ("imagesc: expected data LIMITS to be [lo, hi]");