1## Copyright (C) 2005, 2006, 2007, 2008, 2009 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} {} hold
21## @deftypefnx {Function File} {} hold @var{state}
22## @deftypefnx {Function File} {} hold (@var{hax}, @dots{})
23## Toggle or set the 'hold' state of the plotting engine which determines
24## whether new graphic objects are added to the plot or replace the existing
29## Retain plot data and settings so that subsequent plot commands are displayed
33## Clear plot and restore default graphics settings before each new plot
37## Toggle the current 'hold' state.
40## When given the additional argument @var{hax}, the hold state is modified
41## only for the given axis handle.
43## To query the current 'hold' state use the @code{ishold} function.
44## @seealso{ishold, cla, newplot, clf}
47function hold (varargin)
49 if (nargin > 0 && numel (varargin{1}) == 1 && ishandle (varargin{1})
50 && strcmp (get (varargin{1}, "type"), "axes"))
51 [ax, varargin, nargs] = __plt_get_axis_arg__ ("hold", varargin{:});
52 elseif (nargin > 0 && numel (varargin{1}) > 1 && ishandle (varargin{1}))
57 nargs = numel (varargin);
61 turn_hold_off = ishold (ax);
65 if (strcmpi (state, "off"))
67 elseif (strcmpi (state, "on"))
68 turn_hold_off = false;
70 error ("hold: invalid hold state");
78 set (ax, "nextplot", "replace");
80 set (ax, "nextplot", "add");
81 set (fig, "nextplot", "add");
89%! [X, Y] = find (A > 0.9);
98%! imagesc(1./hilb(4));
105%! imagesc(1./hilb(2));
106%! imagesc(1./hilb(4));
113%! imagesc(1./hilb(4));
119%! t = linspace (-3, 3, 50);
120%! [x, y] = meshgrid (t, t);
122%! contourf (x, y, z, 10);
124%! plot (vec (x), vec (y), "^");
125%! patch ([-1.0 1.0 1.0 -1.0 -1.0], [-1.0 -1.0 1.0 1.0 -1.0], "red");
128%! colorbar ("SouthOutside");
129%! title ("Test script for some plot functions");