Mercurial > hg > octave-lyh
annotate scripts/plot/hold.m @ 10135:4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
author | David Bateman <dbateman@free.fr> |
---|---|
date | Wed, 20 Jan 2010 02:52:22 +0100 |
parents | e381f80a5f7a |
children | 95c3e38098bf |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2005, 2006, 2007, 2008, 2009 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 -*- | |
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 | 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 | 45 ## @end deftypefn |
46 | |
6257 | 47 function hold (varargin) |
5406 | 48 |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
49 if (nargin > 0 && numel (varargin{1}) == 1 && ishandle (varargin{1}) |
8240
5cfeb7bc497a
comet.m,hold.m: validate axes handle
Ben Abbott <bpabbott@mac.com>
parents:
8190
diff
changeset
|
50 && strcmp (get (varargin{1}, "type"), "axes")) |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
51 [ax, varargin, nargs] = __plt_get_axis_arg__ ("hold", varargin{:}); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
52 elseif (nargin > 0 && numel (varargin{1}) > 1 && ishandle (varargin{1})) |
8189
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 |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
55 ax = gca (); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
56 fig = gcf (); |
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
|
57 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
|
58 endif |
5406 | 59 |
6257 | 60 if (nargs == 0) |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
61 turn_hold_off = ishold (ax); |
6257 | 62 elseif (nargs == 1) |
63 state = varargin{1}; | |
64 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
|
65 if (strcmpi (state, "off")) |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
66 turn_hold_off = true; |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
8189
diff
changeset
|
67 elseif (strcmpi (state, "on")) |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
68 turn_hold_off = false; |
6257 | 69 else |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
70 error ("hold: invalid hold state"); |
6257 | 71 endif |
5406 | 72 endif |
73 else | |
6046 | 74 print_usage (); |
5406 | 75 endif |
76 | |
9618
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
77 if (turn_hold_off) |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
78 set (ax, "nextplot", "replace"); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
79 else |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
80 set (ax, "nextplot", "add"); |
e381f80a5f7a
correctly toggle hold state
John W. Eaton <jwe@octave.org>
parents:
9328
diff
changeset
|
81 set (fig, "nextplot", "add"); |
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 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
|
83 |
5406 | 84 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
|
85 |
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
|
86 %!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
|
87 %! 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
|
88 %! 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
|
89 %! [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
|
90 %! 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
|
91 %! 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
|
92 %! 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
|
93 %! 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
|
94 |
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 %!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
|
96 %! 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
|
97 %! 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
|
98 %! 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
|
99 %! 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
|
100 %! 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
|
101 |
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 %!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
|
103 %! 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
|
104 %! 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
|
105 %! 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
|
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 %! 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
|
108 |
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 %!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
|
110 %! 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
|
111 %! 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
|
112 %! 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
|
113 %! 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
|
114 %! 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
|
115 |
9328
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
116 %!demo |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
117 %! clf |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
118 %! colormap (jet) |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
119 %! t = linspace (-3, 3, 50); |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
120 %! [x, y] = meshgrid (t, t); |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
121 %! z = peaks (x, y); |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
122 %! contourf (x, y, z, 10); |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
123 %! hold ("on"); |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
124 %! plot (vec (x), vec (y), "^"); |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
125 %! patch ([-1.0 1.0 1.0 -1.0 -1.0], [-1.0 -1.0 1.0 1.0 -1.0], "red"); |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
126 %! xlim ([-2.0 2.0]); |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
127 %! ylim ([-2.0 2.0]); |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
128 %! colorbar ("SouthOutside"); |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
129 %! title ("Test script for some plot functions"); |
0307f5e5568c
__go_draw_axes__.m: Fix order when pushing group children onto kid list.
Ben Abbott <bpabbott@mac.com>
parents:
9316
diff
changeset
|
130 |