Mercurial > hg > octave-nkf
annotate scripts/plot/hold.m @ 11884:cee2f0ae1dba release-3-0-x
Correct cast of matrix by cell or struct concatenation
author | David Bateman <dbateman@free.fr> |
---|---|
date | Thu, 20 Nov 2008 08:36:37 +0100 |
parents | 965bb17961f0 |
children | 553874dbba84 |
rev | line source |
---|---|
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 |
11824
965bb17961f0
hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
41 if (nargin > 0 && ishandle (varargin{1})) |
965bb17961f0
hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
42 [h, varargin, nargs] = __plt_get_axis_arg__ ("hold", varargin{:}); |
965bb17961f0
hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
43 else |
965bb17961f0
hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
44 h = gcf (); |
965bb17961f0
hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
45 nargs = numel (varargin); |
965bb17961f0
hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
46 endif |
5406 | 47 |
6257 | 48 hold_state = get (h, "nextplot"); |
5406 | 49 |
6257 | 50 if (nargs == 0) |
51 if (strcmp (hold_state, "add")) | |
52 hold_state = "replace"; | |
5406 | 53 else |
6257 | 54 hold_state = "add"; |
55 endif | |
56 elseif (nargs == 1) | |
57 state = varargin{1}; | |
58 if (ischar (state)) | |
59 if (strcmp ("off", state)) | |
60 hold_state = "replace"; | |
61 elseif (strcmp ("on", state)) | |
62 hold_state = "add"; | |
63 else | |
64 print_usage (); | |
65 endif | |
5406 | 66 endif |
67 else | |
6046 | 68 print_usage (); |
5406 | 69 endif |
70 | |
11824
965bb17961f0
hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
71 if (isfigure (h)) |
965bb17961f0
hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
72 axes_objs = findobj (h, "type", "axes"); |
965bb17961f0
hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
73 h = [h; axes_objs]; |
965bb17961f0
hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
74 endif |
965bb17961f0
hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
75 |
6257 | 76 set (h, "nextplot", hold_state); |
77 | |
5406 | 78 endfunction |