annotate scripts/plot/subplot.m @ 12132:dc11166fcddc

subplot.m: Set "box" to "on" by default (same as Matlab).
author Ben Abbott <bpabbott@mac.com>
date Sat, 22 Jan 2011 13:29:43 -0500
parents b0084095098e
children 7b67bbf9dbbb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11472
diff changeset
1 ## Copyright (C) 1995-2011 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
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: 6828
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: 6828
diff changeset
8 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
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: 6828
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: 6828
diff changeset
17 ## <http://www.gnu.org/licenses/>.
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
18
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
20 ## @deftypefn {Function File} {} subplot (@var{rows}, @var{cols}, @var{index})
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
21 ## @deftypefnx {Function File} {} subplot (@var{rcn})
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
22 ## Set up a plot grid with @var{rows} by @var{cols} subwindows and plot
6448
2110cc251779 [project @ 2007-03-24 02:47:36 by jwe]
jwe
parents: 6425
diff changeset
23 ## in location given by @var{index}.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3368
diff changeset
24 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
25 ## If only one argument is supplied, then it must be a three digit value
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
26 ## specifying the location in digits 1 (rows) and 2 (columns) and the plot
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
27 ## index in digit 3.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3368
diff changeset
28 ##
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
29 ## The plot index runs row-wise. First all the columns in a row are filled
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
30 ## and then the next row is filled.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3368
diff changeset
31 ##
5798
7e7ed81f5566 [project @ 2006-05-09 17:24:33 by jwe]
jwe
parents: 5775
diff changeset
32 ## For example, a plot with 2 by 3 grid will have plot indices running as
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
33 ## follows:
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
34 ## @tex
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
35 ## \vskip 10pt
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
36 ## \hfil\vbox{\offinterlineskip\hrule
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
37 ## \halign{\vrule#&&\qquad\hfil#\hfil\qquad\vrule\cr
7107
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7086
diff changeset
38 ## height13pt&1&2&3\cr height12pt&&&\cr\noalign{\hrule}
22397f0fb0b2 [project @ 2007-11-06 20:31:33 by dbateman]
dbateman
parents: 7086
diff changeset
39 ## height13pt&4&5&6\cr height12pt&&&\cr\noalign{\hrule}}}
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
40 ## \hfil
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
41 ## \vskip 10pt
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
42 ## @end tex
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 8350
diff changeset
43 ## @ifnottex
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
44 ##
8350
0e3a92a8683c fix texi bug in subplot.m
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8232
diff changeset
45 ## @example
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
46 ## @group
7040
1f16da18d85d [project @ 2007-10-19 18:24:19 by jwe]
jwe
parents: 7017
diff changeset
47 ## +-----+-----+-----+
1f16da18d85d [project @ 2007-10-19 18:24:19 by jwe]
jwe
parents: 7017
diff changeset
48 ## | 1 | 2 | 3 |
1f16da18d85d [project @ 2007-10-19 18:24:19 by jwe]
jwe
parents: 7017
diff changeset
49 ## +-----+-----+-----+
1f16da18d85d [project @ 2007-10-19 18:24:19 by jwe]
jwe
parents: 7017
diff changeset
50 ## | 4 | 5 | 6 |
1f16da18d85d [project @ 2007-10-19 18:24:19 by jwe]
jwe
parents: 7017
diff changeset
51 ## +-----+-----+-----+
8350
0e3a92a8683c fix texi bug in subplot.m
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8232
diff changeset
52 ## @end group
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6178
diff changeset
53 ## @end example
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
54 ##
8517
81d6ab3ac93c Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents: 8350
diff changeset
55 ## @end ifnottex
5798
7e7ed81f5566 [project @ 2006-05-09 17:24:33 by jwe]
jwe
parents: 5775
diff changeset
56 ## @seealso{plot}
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3233
diff changeset
57 ## @end deftypefn
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
58
2312
204cc7db6f4a [project @ 1996-07-11 21:20:36 by jwe]
jwe
parents: 2311
diff changeset
59 ## Author: Vinayak Dutt <Dutt.Vinayak@mayo.EDU>
204cc7db6f4a [project @ 1996-07-11 21:20:36 by jwe]
jwe
parents: 2311
diff changeset
60 ## Adapted-By: jwe
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
61
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
62 function h = subplot (rows, cols, index, varargin)
11305
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
63
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
64 align_axes = false;
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
65 replace_axes = false;
6163
8614649c454c [project @ 2006-11-14 18:52:34 by jwe]
jwe
parents: 6046
diff changeset
66
11305
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
67 if (! (nargin >= 3) && nargin != 1)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5798
diff changeset
68 print_usage ();
11305
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
69 elseif (nargin > 3)
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
70 for n = 1:numel(varargin)
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
71 switch lower(varargin{n})
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
72 case "align"
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
73 align_axes = true;
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
74 case "replace"
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
75 replace_axes = true;
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
76 otherwise
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
77 print_usage ();
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
78 endswitch
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
79 endfor
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
80 endif
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
81
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
82 if (nargin == 1)
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
83
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3426
diff changeset
84 if (! (isscalar (rows) && rows >= 0))
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 11469
diff changeset
85 error ("subplot: input RCN has to be a positive scalar");
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
86 endif
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
87
1541
47bd45a30dda [project @ 1995-10-06 03:40:11 by jwe]
jwe
parents: 1540
diff changeset
88 tmp = rows;
47bd45a30dda [project @ 1995-10-06 03:40:11 by jwe]
jwe
parents: 1540
diff changeset
89 index = rem (tmp, 10);
47bd45a30dda [project @ 1995-10-06 03:40:11 by jwe]
jwe
parents: 1540
diff changeset
90 tmp = (tmp - index) / 10;
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
91 cols = rem (tmp, 10);
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
92 tmp = (tmp - cols) / 10;
1541
47bd45a30dda [project @ 1995-10-06 03:40:11 by jwe]
jwe
parents: 1540
diff changeset
93 rows = rem (tmp, 10);
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
94
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
95 elseif (! (isscalar (cols) && isscalar (rows)))
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 11469
diff changeset
96 error ("subplot: COLS, and ROWS must be scalars");
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
97 elseif (any (index < 1) || any (index > rows*cols))
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
98 error ("subplot: INDEX value must be greater than 1 and less than ROWS*COLS");
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
99 endif
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
100
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
101 cols = round (cols);
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
102 rows = round (rows);
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
103 index = round (index);
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
104
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
105 if (index > cols*rows)
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 11469
diff changeset
106 error ("subplot: INDEX must be less than COLS*ROWS");
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
107 endif
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
108
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
109 if (cols < 1 || rows < 1 || index < 1)
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 11469
diff changeset
110 error ("subplot: COLS,ROWS,INDEX must be be positive");
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
111 endif
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
112
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
113 units = get (0, "defaultaxesunits");
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
114 unwind_protect
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
115 set (0, "defaultaxesunits", "normalized");
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
116 pos = subplot_position (rows, cols, index, "position", units);
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
117
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
118 cf = gcf ();
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
119
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
120 set (cf, "nextplot", "add");
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
121
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
122 found = false;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
123 kids = get (cf, "children");
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
124 for child = reshape (kids, 1, numel (kids))
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
125 ## Check whether this child is still valid; this might not be the
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
126 ## case anymore due to the deletion of previous children (due to
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
127 ## "deletefcn" callback or for legends/colorbars that are deleted
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
128 ## with their corresponding axes).
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
129 if (! ishandle (child))
7086
625891845df5 [project @ 2007-10-31 17:11:49 by jwe]
jwe
parents: 7040
diff changeset
130 continue;
625891845df5 [project @ 2007-10-31 17:11:49 by jwe]
jwe
parents: 7040
diff changeset
131 endif
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
132 if (strcmp (get (child, "type"), "axes"))
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
133 ## Skip legend and colorbar objects.
11149
fe3c3dfc07eb style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents: 10931
diff changeset
134 if (strcmp (get (child, "tag"), "legend")
fe3c3dfc07eb style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents: 10931
diff changeset
135 || strcmp (get (child, "tag"), "colorbar"))
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
136 continue;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
137 endif
8804
995f8b064b32 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8744
diff changeset
138 objpos = get (child, "position");
11305
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
139 if (all (objpos == pos) && ! replace_axes)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
140 ## If the new axes are in exactly the same position as an
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
141 ## existing axes object, use the existing axes.
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
142 found = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
143 tmp = child;
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
144 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
145 ## If the new axes overlap an old axes object, delete the old
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
146 ## axes.
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
147 x0 = pos(1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
148 x1 = x0 + pos(3);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
149 y0 = pos(2);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
150 y1 = y0 + pos(4);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
151 objx0 = objpos(1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
152 objx1 = objx0 + objpos(3);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
153 objy0 = objpos(2);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
154 objy1 = objy0 + objpos(4);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
155 if (! (x0 >= objx1 || x1 <= objx0 || y0 >= objy1 || y1 <= objy0))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
156 delete (child);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9211
diff changeset
157 endif
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
158 endif
6178
830235f4984f [project @ 2006-11-17 00:16:57 by jwe]
jwe
parents: 6163
diff changeset
159 endif
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
160 endfor
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
161
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
162 if (found)
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
163 set (cf, "currentaxes", tmp);
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
164 else
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
165 pos = subplot_position (rows, cols, index, "outerposition", units);
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
166 pos2 = subplot_position (rows, cols, index, "position", units);
11305
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
167 tmp = axes ("outerposition", pos, "position", pos2,
12132
dc11166fcddc subplot.m: Set "box" to "on" by default (same as Matlab).
Ben Abbott <bpabbott@mac.com>
parents: 11589
diff changeset
168 "activepositionproperty", "outerposition",
dc11166fcddc subplot.m: Set "box" to "on" by default (same as Matlab).
Ben Abbott <bpabbott@mac.com>
parents: 11589
diff changeset
169 "box", "off");
11305
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
170 endif
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
171
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
172 if (align_axes && strcmp (get (cf, "__graphics_toolkit__"), "gnuplot"))
11305
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
173 set (tmp, "activepositionproperty", "position");
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
174 endif
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
175
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
176 unwind_protect_cleanup
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
177 set (0, "defaultaxesunits", units);
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
178 end_unwind_protect
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
179
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6178
diff changeset
180 if (nargout > 0)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6178
diff changeset
181 h = tmp;
1540
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
182 endif
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
183
749b8b19733f [project @ 1995-10-06 03:10:34 by jwe]
jwe
parents:
diff changeset
184 endfunction
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
185
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
186 function pos = subplot_position (rows, cols, index, position_property, units)
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
187
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
188 ## For 1 row and 1 column return the usual default.
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
189 if (rows == 1 && cols == 1)
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
190 if (strcmpi (position_property, "position"))
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
191 pos = get (0, "defaultaxesposition");
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
192 else
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
193 pos = get (0, "defaultaxesouterposition");
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
194 endif
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
195 return
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
196 endif
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
197
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
198 ## This produces compatible behavior for the "position" property.
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
199 margins.left = 0.130;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
200 margins.right = 0.095;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
201 margins.top = 0.075;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
202 margins.bottom = 0.110;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
203 pc = 1 ./ [0.1860, (margins.left + margins.right - 1)];
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
204 margins.column = 1 ./ polyval (pc , cols);
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
205 pr = 1 ./ [0.2282, (margins.top + margins.bottom - 1)];
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
206 margins.row = 1 ./ polyval (pr , rows);
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
207
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
208 ## Calculate the width/height of the subplot axes.
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
209 width = 1 - margins.left - margins.right - (cols-1)*margins.column;
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
210 width = width / cols;
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
211 height = 1 - margins.top - margins.bottom - (rows-1)*margins.row;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
212 height = height / rows;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
213
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
214 if (strcmp (position_property, "outerposition") )
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
215 ## Calculate the outerposition/position inset
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
216 if (rows > 1)
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
217 inset.top = 8/420;
8804
995f8b064b32 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8744
diff changeset
218 inset.bottom = max (polyval ([0.1382,-0.0026], height), 16/420);
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
219 else
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
220 inset.bottom = margins.bottom;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
221 inset.top = margins.top;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
222 endif
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
223 if (cols > 1)
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
224 if (strcmpi (units, "normalized"))
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
225 inset.right = max (polyval ([0.1200,-0.0014], width), 5/560);
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
226 else
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
227 inset.right = max (polyval ([0.1252,-0.0023], width), 5/560);
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
228 endif
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
229 inset.left = 22/560;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
230 else
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
231 inset.left = margins.left;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
232 inset.right = margins.right;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
233 endif
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
234 ## Apply the inset to the geometries for the "position" property.
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
235 margins.column = margins.column - inset.right - inset.left;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
236 margins.row = margins.row - inset.top - inset.bottom;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
237 width = width + inset.right + inset.left;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
238 height = height + inset.top + inset.bottom;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
239 endif
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
240
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
241 yp = fix ((index(:)-1)/cols);
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11305
diff changeset
242 xp = index(:) - yp*cols - 1;
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
243 yp = (rows - 1) - yp;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
244
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
245 x0 = xp .* (width + margins.column) + margins.left;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
246 y0 = yp .* (height + margins.row) + margins.bottom;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
247
8804
995f8b064b32 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8744
diff changeset
248 if (strcmp (position_property, "outerposition") )
995f8b064b32 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8744
diff changeset
249 x0 = x0 - inset.left;
995f8b064b32 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8744
diff changeset
250 y0 = y0 - inset.bottom;
995f8b064b32 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8744
diff changeset
251 endif
995f8b064b32 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8744
diff changeset
252
8744
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
253 if (numel(x0) > 1)
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
254 x1 = max (x0) + width;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
255 y1 = max (y0) + height;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
256 x0 = min (x0);
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
257 y0 = min (y0);
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
258 pos = [x0, y0, x1-x0, y1-y0];
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
259 else
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
260 pos = [x0, y0, width, height];
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
261 endif
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
262
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
263 endfunction
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
264
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
265 %!demo
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
266 %! clf
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
267 %! r = 3;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
268 %! c = 3;
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
269 %! fmt = {'horizontalalignment', 'center', 'verticalalignment', 'middle'};
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
270 %! for n = 1:(r*c)
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
271 %! subplot (r, c, n)
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
272 %! xlabel (sprintf ("xlabel #%d", n))
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
273 %! ylabel (sprintf ("ylabel #%d", n))
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
274 %! title (sprintf ("title #%d", n))
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
275 %! text (0.5, 0.5, sprintf('subplot(%d,%d,%d)', r, c, n), fmt{:})
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
276 %! axis ([0 1 0 1])
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
277 %! endfor
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
278 %! subplot (r, c, 1:3)
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
279 %! xlabel (sprintf ("xlabel #%d:%d", 1, 3))
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
280 %! ylabel (sprintf ("ylabel #%d:%d", 1, 3))
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
281 %! title (sprintf ("title #%d:%d", 1, 3))
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
282 %! text (0.5, 0.5, sprintf('subplot(%d,%d,%d:%d)', r, c, 1, 3), fmt{:})
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
283 %! axis ([0 1 0 1])
4142982c66c6 subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents: 8517
diff changeset
284
11305
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
285 %!demo
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
286 %! clf
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
287 %! x = 0:1;
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
288 %! for n = 1:4
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
289 %! subplot (2, 2, n, "align")
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
290 %! plot (x, x)
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
291 %! xlabel (sprintf ("xlabel (2,2,%d)", n))
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
292 %! ylabel (sprintf ("ylabel (2,2,%d)", n))
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
293 %! title (sprintf ("title (2,2,%d)", n))
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
294 %! endfor
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
295 %! subplot (1, 2, 1, "align")
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
296 %! plot (x, x)
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
297 %! xlabel (sprintf ("xlabel (1,2,%d)", n))
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
298 %! ylabel (sprintf ("ylabel (1,2,%d)", n))
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
299 %! title (sprintf ("title (1,2,%d)", n))
c9df571efe95 subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents: 11149
diff changeset
300