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