annotate scripts/plot/hold.m @ 9316:c539ec5726e7

Update some of Advanced Plotting documentation. Updated functions delete, allchild, backend, clf, hold, and refreshdata.
author Rik <rdrider0-list@yahoo.com>
date Sun, 07 Jun 2009 20:12:16 -0700
parents 3eda945bda43
children 0307f5e5568c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8746
diff changeset
1 ## Copyright (C) 2005, 2006, 2007, 2008, 2009 John W. Eaton
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
2 ##
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
4 ##
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6713
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6713
diff changeset
8 ## your option) any later version.
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
9 ##
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
14 ##
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6713
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6713
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
18
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
9316
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
20 ## @deftypefn {Function File} {} hold
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
21 ## @deftypefnx {Function File} {} hold @var{state}
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
22 ## @deftypefnx {Function File} {} hold (@var{hax}, @dots{})
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
23 ## Toggle or set the 'hold' state of the plotting engine which determines
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
24 ## whether new graphic objects are added to the plot or replace the existing
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
25 ## objects.
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
26 ##
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
27 ## @table @code
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
28 ## @item hold on
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
29 ## Retain plot data and settings so that subsequent plot commands are displayed
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
30 ## on a single graph.
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
31 ##
9316
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
32 ## @item hold off
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
33 ## Clear plot and restore default graphics settings before each new plot
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
34 ## command. (default).
7985
85c5c1d55820 hold.m: Trival mod to help text.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
35 ##
9316
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
36 ## @item hold
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
37 ## Toggle the current 'hold' state.
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
38 ## @end table
7985
85c5c1d55820 hold.m: Trival mod to help text.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
39 ##
9316
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
40 ## When given the additional argument @var{hax}, the hold state is modified
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
41 ## only for the given axis handle.
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
42 ##
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
43 ## To query the current 'hold' state use the @code{ishold} function.
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9272
diff changeset
44 ## @seealso{ishold, cla, newplot, clf}
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
45 ## @end deftypefn
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
46
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
47 function hold (varargin)
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
48
8240
5cfeb7bc497a comet.m,hold.m: validate axes handle
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
49 if (nargin > 0 && numel (varargin{1}) == 1 && ishandle (varargin{1}(1))
5cfeb7bc497a comet.m,hold.m: validate axes handle
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
50 && strcmp (get (varargin{1}, "type"), "axes"))
8065
6333da0dfdfd hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents: 7985
diff changeset
51 [h, varargin, nargs] = __plt_get_axis_arg__ ("hold", varargin{:});
8189
8e8afefe9466 Remove reliance on ishandle(vec) == false.
Ben Abbott <bpabbott@mac.com>
parents: 8075
diff changeset
52 elseif (nargin > 0 && numel (varargin{1}) > 1 && ishandle (varargin{1}(1)))
8e8afefe9466 Remove reliance on ishandle(vec) == false.
Ben Abbott <bpabbott@mac.com>
parents: 8075
diff changeset
53 print_usage ();
8065
6333da0dfdfd hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents: 7985
diff changeset
54 else
6333da0dfdfd hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents: 7985
diff changeset
55 h = gcf ();
6333da0dfdfd hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents: 7985
diff changeset
56 nargs = numel (varargin);
6333da0dfdfd hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents: 7985
diff changeset
57 endif
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
58
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
59 hold_state = get (h, "nextplot");
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
60
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
61 if (nargs == 0)
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 8189
diff changeset
62 if (strcmpi (hold_state, "add"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
63 hold_state = "replace";
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
64 else
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
65 hold_state = "add";
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
66 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
67 elseif (nargs == 1)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
68 state = varargin{1};
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
69 if (ischar (state))
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 8189
diff changeset
70 if (strcmpi (state, "off"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
71 hold_state = "replace";
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 8189
diff changeset
72 elseif (strcmpi (state, "on"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
73 hold_state = "add";
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
74 else
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
75 print_usage ();
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
76 endif
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
77 endif
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
78 else
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5406
diff changeset
79 print_usage ();
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
80 endif
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
81
8065
6333da0dfdfd hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents: 7985
diff changeset
82 if (isfigure (h))
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8065
diff changeset
83 if (isempty (get (h, "currentaxes")))
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8065
diff changeset
84 set (h, "currentaxes", __go_axes__ (h))
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8065
diff changeset
85 endif
8065
6333da0dfdfd hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents: 7985
diff changeset
86 axes_objs = findobj (h, "type", "axes");
6333da0dfdfd hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents: 7985
diff changeset
87 h = [h; axes_objs];
6333da0dfdfd hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents: 7985
diff changeset
88 endif
6333da0dfdfd hold.m: if hold is applied to a figure, set state for all child axes objects
John W. Eaton <jwe@octave.org>
parents: 7985
diff changeset
89
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
90 set (h, "nextplot", hold_state);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
91
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
92 endfunction
9272
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
93
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
94 %!demo
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
95 %! clf
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
96 %! A = rand (100);
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
97 %! [X, Y] = find (A > 0.9);
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
98 %! imshow (A)
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
99 %! hold on
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
100 %! plot (X, Y, 'o')
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
101 %! hold off
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
102
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
103 %!demo
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
104 %! clf
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
105 %! hold on
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
106 %! imagesc(1./hilb(4));
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
107 %! plot (1:4, "-s")
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
108 %! hold off
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
109
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
110 %!demo
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
111 %! clf
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
112 %! hold on
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
113 %! imagesc(1./hilb(2));
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
114 %! imagesc(1./hilb(4));
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
115 %! hold off
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
116
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
117 %!demo
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
118 %! clf
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
119 %! hold on
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
120 %! plot (1:4, "-s")
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
121 %! imagesc(1./hilb(4));
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
122 %! hold off
3eda945bda43 __go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
123