annotate scripts/plot/hold.m @ 9272:3eda945bda43

__go_draw_axes__.m: Fix rendering of overlaping images and line objects. Add demos as well.
author Ben Abbott <bpabbott@mac.com>
date Tue, 26 May 2009 21:16:54 -0400
parents eb63fbe60fab
children c539ec5726e7
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 -*-
6713
26f3d9bf9562 [project @ 2007-06-13 10:34:14 by dbateman]
dbateman
parents: 6257
diff changeset
20 ## @deftypefn {Function File} {} hold @var{args}
7985
85c5c1d55820 hold.m: Trival mod to help text.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
21 ## Tell Octave to `hold' the current data on the graph when executing
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
22 ## subsequent plotting commands. This allows you to execute a series of
7985
85c5c1d55820 hold.m: Trival mod to help text.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
23 ## plot commands and have all the lines end up on the same graph. The
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
24 ## default is for each new plot command to clear the plot device first.
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
25 ## For example, the command
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
26 ##
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
27 ## @example
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
28 ## hold on
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
29 ## @end example
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
30 ##
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
31 ## @noindent
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
32 ## turns the hold state on. An argument of @code{"off"} turns the hold
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
33 ## state off, and @code{hold} with no arguments toggles the current hold
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
34 ## state.
7985
85c5c1d55820 hold.m: Trival mod to help text.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
35 ##
85c5c1d55820 hold.m: Trival mod to help text.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
36 ## @deftypefnx {Function File} {} hold (@var{h}, @dots{})
85c5c1d55820 hold.m: Trival mod to help text.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
37 ##
85c5c1d55820 hold.m: Trival mod to help text.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
38 ## Applies to a specific axis or axes, associated with the handle(s),
85c5c1d55820 hold.m: Trival mod to help text.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
39 ## @var{h}.
85c5c1d55820 hold.m: Trival mod to help text.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
40 ##
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
41 ## @end deftypefn
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
42
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
43 function hold (varargin)
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
44
8240
5cfeb7bc497a comet.m,hold.m: validate axes handle
Ben Abbott <bpabbott@mac.com>
parents: 8190
diff changeset
45 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
46 && 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
47 [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
48 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
49 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
50 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
51 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
52 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
53 endif
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
54
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
55 hold_state = get (h, "nextplot");
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
56
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
57 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
58 if (strcmpi (hold_state, "add"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
59 hold_state = "replace";
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
60 else
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
61 hold_state = "add";
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
62 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
63 elseif (nargs == 1)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
64 state = varargin{1};
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
65 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
66 if (strcmpi (state, "off"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
67 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
68 elseif (strcmpi (state, "on"))
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
69 hold_state = "add";
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
70 else
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
71 print_usage ();
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
72 endif
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
73 endif
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
74 else
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5406
diff changeset
75 print_usage ();
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
76 endif
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
77
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
78 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
79 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
80 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
81 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
82 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
83 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
84 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
85
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
86 set (h, "nextplot", hold_state);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
87
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents:
diff changeset
88 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
89
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
90 %!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
91 %! 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
92 %! 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
93 %! [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
94 %! 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
95 %! 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
96 %! 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
97 %! 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
98
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 %!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
100 %! 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
101 %! 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
102 %! 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
103 %! 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
104 %! 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
105
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 %!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
107 %! 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
108 %! 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
109 %! 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
110 %! 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
111 %! 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
112
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 %!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
114 %! 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
115 %! 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
116 %! 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
117 %! 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
118 %! 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
119