1## Copyright (C) 1996, 1997, 1999, 2000, 2004, 2005, 2006, 2007
4## This file is part of Octave.
6## Octave is free software; you can redistribute it and/or modify it
7## under the terms of the GNU General Public License as published by
8## the Free Software Foundation; either version 3 of the License, or (at
9## your option) any later version.
11## Octave is distributed in the hope that it will be useful, but
12## WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14## General Public License for more details.
16## You should have received a copy of the GNU General Public License
17## along with Octave; see the file COPYING. If not, see
18## <http://www.gnu.org/licenses/>.
21## @deftypefn {Function File} {} figure (@var{n})
22## @deftypefnx {Function File} {} figure (@var{n}, @var{property}, @var{value}, @dots{})
23## Set the current plot window to plot window @var{n}. If no arguments are
24## specified, the next available window number is chosen.
26## Multiple property-value pairs may be specified for the figure, but they
27## must appear in pairs.
30## Author: jwe, Bill Denney
32function h = figure (varargin)
38 init_new_figure = false;
39 if (mod (nargs, 2) == 1)
41 if (ishandle (tmp) && strcmp (get (tmp, "type"), "figure"))
45 elseif (isnumeric (tmp) && tmp > 0 && round (tmp) == tmp)
47 init_new_figure = true;
51 error ("figure: expecting figure handle or figure number");
55 ## Check to see if we already have a figure on the screen. If we do,
56 ## then update it if it is different from the figure we are creating
58 cf = get (0, "currentfigure");
59 if (! isempty (cf) && cf != 0)
60 if (isnan (f) || cf != f)
65 if (rem (nargs, 2) == 0)
66 if (isnan (f) || init_new_figure)
67 f = __go_figure__ (f, varargin{:});
71 set (0, "currentfigure", f);