7017
|
1 ## Copyright (C) 2005, 2006, 2007 John W. Eaton |
5406
|
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 |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
5406
|
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 |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
5406
|
18 |
|
19 ## -*- texinfo -*- |
6713
|
20 ## @deftypefn {Function File} {} hold @var{args} |
5406
|
21 ## Tell Octave to `hold' the current data on the plot when executing |
|
22 ## subsequent plotting commands. This allows you to execute a series of |
|
23 ## plot commands and have all the lines end up on the same figure. The |
|
24 ## default is for each new plot command to clear the plot device first. |
|
25 ## For example, the command |
|
26 ## |
|
27 ## @example |
|
28 ## hold on |
|
29 ## @end example |
|
30 ## |
|
31 ## @noindent |
|
32 ## turns the hold state on. An argument of @code{"off"} turns the hold |
|
33 ## state off, and @code{hold} with no arguments toggles the current hold |
|
34 ## state. |
|
35 ## @end deftypefn |
|
36 |
|
37 ## PKG_ADD: mark_as_command hold |
|
38 |
6257
|
39 function hold (varargin) |
5406
|
40 |
6257
|
41 [h, varargin] = __plt_get_axis_arg__ ("hold", varargin{:}); |
5406
|
42 |
6257
|
43 hold_state = get (h, "nextplot"); |
5406
|
44 |
6257
|
45 nargs = numel (varargin); |
5406
|
46 |
6257
|
47 if (nargs == 0) |
|
48 if (strcmp (hold_state, "add")) |
|
49 hold_state = "replace"; |
5406
|
50 else |
6257
|
51 hold_state = "add"; |
|
52 endif |
|
53 elseif (nargs == 1) |
|
54 state = varargin{1}; |
|
55 if (ischar (state)) |
|
56 if (strcmp ("off", state)) |
|
57 hold_state = "replace"; |
|
58 elseif (strcmp ("on", state)) |
|
59 hold_state = "add"; |
|
60 else |
|
61 print_usage (); |
|
62 endif |
5406
|
63 endif |
|
64 else |
6046
|
65 print_usage (); |
5406
|
66 endif |
|
67 |
6257
|
68 set (h, "nextplot", hold_state); |
|
69 |
5406
|
70 endfunction |