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 -*- |
|
21 ## @deftypefn {Built-in Function} {} hold @var{args} |
|
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 |
|
40 function hold (arg) |
|
41 |
|
42 global __current_figure__; |
|
43 global __hold_state__; |
|
44 |
|
45 if (isempty (__current_figure__)) |
|
46 __current_figure__ = 1; |
|
47 endif |
|
48 |
|
49 if (isempty (__hold_state__)) |
|
50 __hold_state__ = false; |
|
51 endif |
|
52 |
|
53 if (length (__hold_state__) < __current_figure__) |
|
54 __hold_state__(__current_figure__) = false; |
|
55 endif |
|
56 |
|
57 usage_msg = "hold (\"on\") or hold (\"off\")"; |
|
58 |
|
59 if (nargin == 0) |
|
60 __hold_state__(__current_figure__) = ! __hold_state__(__current_figure__); |
|
61 elseif (nargin == 1) |
|
62 if (strcmp (arg, "on")) |
|
63 __hold_state__(__current_figure__) = true; |
|
64 elseif (strcmp (arg, "off")) |
|
65 __hold_state__(__current_figure__) = false; |
|
66 else |
|
67 usage (usage_msg); |
|
68 endif |
|
69 else |
|
70 usage (usage_msg); |
|
71 endif |
|
72 |
|
73 endfunction |