Mercurial > hg > octave-nkf
annotate scripts/plot/subplot.m @ 17281:bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Macro handles options ("on") or properties ("position") more elegantly
than @code{"text"}.
* doc/interpreter/macros.texi: Add new @qcode macro.
* doc/interpreter/tips.txi: Add documentation about @qcode macro.
* doc/interpreter/basics.txi, doc/interpreter/container.txi,
doc/interpreter/emacs.txi, doc/interpreter/errors.txi,
doc/interpreter/eval.txi, doc/interpreter/expr.txi,
doc/interpreter/external.txi, doc/interpreter/func.txi,
doc/interpreter/grammar.txi, doc/interpreter/image.txi,
doc/interpreter/install.txi, doc/interpreter/interp.txi,
doc/interpreter/io.txi, doc/interpreter/matrix.txi,
doc/interpreter/numbers.txi, doc/interpreter/oop.txi,
doc/interpreter/package.txi, doc/interpreter/plot.txi,
doc/interpreter/quad.txi, doc/interpreter/sparse.txi,
doc/interpreter/strings.txi, doc/interpreter/system.txi,
doc/interpreter/vectorize.txi, libinterp/corefcn/balance.cc,
libinterp/corefcn/bitfcns.cc, libinterp/corefcn/cellfun.cc,
libinterp/corefcn/conv2.cc, libinterp/corefcn/data.cc,
libinterp/corefcn/debug.cc, libinterp/corefcn/defaults.cc,
libinterp/corefcn/dirfns.cc, libinterp/corefcn/dlmread.cc,
libinterp/corefcn/error.cc, libinterp/corefcn/file-io.cc,
libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc,
libinterp/corefcn/graphics.cc, libinterp/corefcn/help.cc,
libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc,
libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc,
libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lu.cc,
libinterp/corefcn/luinc.cc, libinterp/corefcn/matrix_type.cc,
libinterp/corefcn/oct-hist.cc, libinterp/corefcn/pager.cc,
libinterp/corefcn/pr-output.cc, libinterp/corefcn/pt-jit.cc,
libinterp/corefcn/qz.cc, libinterp/corefcn/rand.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc,
libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sparse.cc,
libinterp/corefcn/spparms.cc, libinterp/corefcn/str2double.cc,
libinterp/corefcn/svd.cc, libinterp/corefcn/symtab.cc,
libinterp/corefcn/syscalls.cc, libinterp/corefcn/toplev.cc,
libinterp/corefcn/tril.cc, libinterp/corefcn/typecast.cc,
libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc,
libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/chol.cc,
libinterp/dldfcn/colamd.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc,
libinterp/dldfcn/symbfact.cc, libinterp/octave-value/ov-base.cc,
libinterp/octave-value/ov-fcn-handle.cc,
libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc,
libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-struct.cc,
libinterp/octave-value/ov-usr-fcn.cc, libinterp/parse-tree/oct-parse.in.yy,
libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-eval.cc,
libinterp/parse-tree/pt-mat.cc, scripts/@ftp/ftp.m,
scripts/deprecated/java_convert_matrix.m, scripts/deprecated/java_debug.m,
scripts/deprecated/java_unsigned_conversion.m, scripts/deprecated/shell_cmd.m,
scripts/general/dblquad.m, scripts/general/display.m,
scripts/general/genvarname.m, scripts/general/idivide.m,
scripts/general/interp1.m, scripts/general/interp2.m,
scripts/general/interp3.m, scripts/general/interpn.m, scripts/general/isa.m,
scripts/general/profexplore.m, scripts/general/profile.m,
scripts/general/quadgk.m, scripts/general/randi.m, scripts/general/structfun.m,
scripts/general/subsindex.m, scripts/general/triplequad.m,
scripts/geometry/griddata.m, scripts/geometry/griddata3.m,
scripts/geometry/griddatan.m, scripts/geometry/voronoi.m, scripts/help/help.m,
scripts/help/lookfor.m, scripts/image/cmpermute.m, scripts/image/colormap.m,
scripts/image/image.m, scripts/image/imagesc.m, scripts/image/imfinfo.m,
scripts/image/imformats.m, scripts/image/imread.m, scripts/image/imshow.m,
scripts/image/imwrite.m, scripts/image/ind2gray.m, scripts/image/lines.m,
scripts/image/rgb2ind.m, scripts/image/spinmap.m, scripts/io/dlmwrite.m,
scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m,
scripts/java/javaclasspath.m, scripts/java/usejava.m,
scripts/miscellaneous/bzip2.m, scripts/miscellaneous/computer.m,
scripts/miscellaneous/copyfile.m, scripts/miscellaneous/debug.m,
scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m,
scripts/miscellaneous/gzip.m, scripts/miscellaneous/license.m,
scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/movefile.m,
scripts/miscellaneous/parseparams.m, scripts/miscellaneous/unix.m,
scripts/optimization/fminbnd.m, scripts/optimization/fminsearch.m,
scripts/optimization/fminunc.m, scripts/optimization/fsolve.m,
scripts/optimization/fzero.m, scripts/optimization/glpk.m,
scripts/optimization/lsqnonneg.m, scripts/optimization/optimset.m,
scripts/optimization/pqpnonneg.m, scripts/pkg/pkg.m, scripts/plot/allchild.m,
scripts/plot/ancestor.m, scripts/plot/area.m, scripts/plot/axis.m,
scripts/plot/bar.m, scripts/plot/barh.m, scripts/plot/box.m,
scripts/plot/caxis.m, scripts/plot/cla.m, scripts/plot/clabel.m,
scripts/plot/clf.m, scripts/plot/close.m, scripts/plot/colorbar.m,
scripts/plot/daspect.m, scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m,
scripts/plot/ezsurf.m, scripts/plot/ezsurfc.m, scripts/plot/findall.m,
scripts/plot/findobj.m, scripts/plot/gcbo.m, scripts/plot/gcf.m,
scripts/plot/gco.m, scripts/plot/grid.m, scripts/plot/guihandles.m,
scripts/plot/hdl2struct.m, scripts/plot/hidden.m, scripts/plot/hold.m,
scripts/plot/isonormals.m, scripts/plot/isosurface.m, scripts/plot/legend.m,
scripts/plot/mesh.m, scripts/plot/meshc.m, scripts/plot/meshz.m,
scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m,
scripts/plot/patch.m, scripts/plot/pbaspect.m, scripts/plot/pcolor.m,
scripts/plot/plot.m, scripts/plot/print.m,
scripts/plot/private/__add_default_menu__.m, scripts/plot/quiver.m,
scripts/plot/quiver3.m, scripts/plot/refreshdata.m, scripts/plot/saveas.m,
scripts/plot/scatter.m, scripts/plot/scatter3.m, scripts/plot/shading.m,
scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/stem.m,
scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m,
scripts/plot/surf.m, scripts/plot/surfc.m, scripts/plot/surfl.m,
scripts/plot/tetramesh.m, scripts/plot/uigetfile.m, scripts/plot/uimenu.m,
scripts/plot/uiputfile.m, scripts/plot/waterfall.m, scripts/plot/whitebg.m,
scripts/plot/xlim.m, scripts/plot/ylim.m, scripts/plot/zlim.m,
scripts/polynomial/conv.m, scripts/polynomial/polyout.m,
scripts/polynomial/splinefit.m, scripts/set/ismember.m, scripts/set/powerset.m,
scripts/set/setdiff.m, scripts/set/union.m, scripts/set/unique.m,
scripts/signal/detrend.m, scripts/signal/filter2.m, scripts/signal/freqz.m,
scripts/signal/periodogram.m, scripts/signal/spectral_adf.m,
scripts/signal/spectral_xdf.m, scripts/sparse/eigs.m, scripts/sparse/svds.m,
scripts/specfun/legendre.m, scripts/special-matrix/gallery.m,
scripts/statistics/base/mean.m, scripts/statistics/base/moment.m,
scripts/statistics/tests/cor_test.m,
scripts/statistics/tests/kolmogorov_smirnov_test.m,
scripts/statistics/tests/kolmogorov_smirnov_test_2.m,
scripts/statistics/tests/kruskal_wallis_test.m,
scripts/statistics/tests/prop_test_2.m, scripts/statistics/tests/sign_test.m,
scripts/statistics/tests/t_test.m, scripts/statistics/tests/t_test_2.m,
scripts/statistics/tests/t_test_regression.m,
scripts/statistics/tests/u_test.m, scripts/statistics/tests/var_test.m,
scripts/statistics/tests/welch_test.m,
scripts/statistics/tests/wilcoxon_test.m, scripts/statistics/tests/z_test.m,
scripts/statistics/tests/z_test_2.m, scripts/strings/base2dec.m,
scripts/strings/index.m, scripts/strings/isstrprop.m,
scripts/strings/mat2str.m, scripts/strings/regexptranslate.m,
scripts/strings/rindex.m, scripts/strings/str2num.m, scripts/strings/strcat.m,
scripts/strings/strjust.m, scripts/strings/strmatch.m,
scripts/strings/validatestring.m, scripts/testfun/demo.m,
scripts/testfun/example.m, scripts/testfun/test.m, scripts/time/addtodate.m,
scripts/time/asctime.m, scripts/time/datestr.m, scripts/time/datetick.m,
scripts/time/weekday.m, scripts/ui/errordlg.m, scripts/ui/helpdlg.m,
scripts/ui/inputdlg.m, scripts/ui/listdlg.m, scripts/ui/msgbox.m,
scripts/ui/questdlg.m, scripts/ui/warndlg.m: Use new @qcode macro.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 19 Aug 2013 20:46:38 -0700 |
parents | eaab03308c0b |
children | 8520c264619c |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13794
diff
changeset
|
1 ## Copyright (C) 1995-2012 John W. Eaton |
2313 | 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. | |
2313 | 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/>. | |
1540 | 18 |
3368 | 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 | 21 ## @deftypefnx {Function File} {} subplot (@var{rcn}) |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
22 ## @deftypefnx {Function File} {} subplot (@dots{}, "align") |
17095
e38820d1124c
correct typo in doc
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17085
diff
changeset
|
23 ## @deftypefnx {Function File} {@var{hax} =} subplot (@dots{}) |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
24 ## @deftypefnx {Function File} {@var{hax} =} subplot (@dots{}) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
25 ## Set up a plot grid with @var{rows} by @var{cols} subwindows and set the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
26 ## current axes for plotting to the location given by @var{index}. |
3426 | 27 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
28 ## If only one numeric argument is supplied, then it must be a three digit |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
29 ## value specifying the location in digits 1 (rows) and 2 (columns) and the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
30 ## plot index in digit 3. |
17085
d3ebc3f9bdbf
doc update for grid and subplot
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17022
diff
changeset
|
31 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
32 ## The plot index runs row-wise. First all the columns in a row are numbered |
3368 | 33 ## and then the next row is filled. |
3426 | 34 ## |
5798 | 35 ## For example, a plot with 2 by 3 grid will have plot indices running as |
2311 | 36 ## follows: |
3368 | 37 ## @tex |
38 ## \vskip 10pt | |
39 ## \hfil\vbox{\offinterlineskip\hrule | |
40 ## \halign{\vrule#&&\qquad\hfil#\hfil\qquad\vrule\cr | |
7107 | 41 ## height13pt&1&2&3\cr height12pt&&&\cr\noalign{\hrule} |
42 ## height13pt&4&5&6\cr height12pt&&&\cr\noalign{\hrule}}} | |
3368 | 43 ## \hfil |
44 ## \vskip 10pt | |
45 ## @end tex | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8350
diff
changeset
|
46 ## @ifnottex |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
47 ## |
8350
0e3a92a8683c
fix texi bug in subplot.m
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8232
diff
changeset
|
48 ## @example |
3368 | 49 ## @group |
7040 | 50 ## +-----+-----+-----+ |
51 ## | 1 | 2 | 3 | | |
52 ## +-----+-----+-----+ | |
53 ## | 4 | 5 | 6 | | |
54 ## +-----+-----+-----+ | |
8350
0e3a92a8683c
fix texi bug in subplot.m
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8232
diff
changeset
|
55 ## @end group |
6257 | 56 ## @end example |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
57 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
58 ## @end ifnottex |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
59 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
60 ## @var{index} may also be a vector. In this case, the new axis will enclose |
12575
d0b799dafede
Grammarcheck files for 3.4.1 release.
Rik <octave@nomad.inbox5.com>
parents:
12494
diff
changeset
|
61 ## the grid locations specified. The first demo illustrates an example: |
12476
070214996fba
subplot.m: Document using INDEX as a vector.
Ben Abbott <bpabbott@mac.com>
parents:
12470
diff
changeset
|
62 ## |
070214996fba
subplot.m: Document using INDEX as a vector.
Ben Abbott <bpabbott@mac.com>
parents:
12470
diff
changeset
|
63 ## @example |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
64 ## demo ("subplot", 1) |
12476
070214996fba
subplot.m: Document using INDEX as a vector.
Ben Abbott <bpabbott@mac.com>
parents:
12470
diff
changeset
|
65 ## @end example |
070214996fba
subplot.m: Document using INDEX as a vector.
Ben Abbott <bpabbott@mac.com>
parents:
12470
diff
changeset
|
66 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
67 ## If the option @qcode{"align"} is given then the plot boxes of the subwindows |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
68 ## will align, but this may leave no room for axis tick marks or labels. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
69 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
70 ## If the output @var{hax} is requested, subplot returns the axis handle for |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
71 ## the subplot. This is useful for modifying the properties of a subplot. |
12476
070214996fba
subplot.m: Document using INDEX as a vector.
Ben Abbott <bpabbott@mac.com>
parents:
12470
diff
changeset
|
72 ## @seealso{axes, plot} |
3368 | 73 ## @end deftypefn |
1540 | 74 |
2312 | 75 ## Author: Vinayak Dutt <Dutt.Vinayak@mayo.EDU> |
76 ## Adapted-By: jwe | |
1540 | 77 |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
78 function h = subplot (varargin) |
11305
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
79 |
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
80 align_axes = false; |
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
81 replace_axes = false; |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
82 have_position = false; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
83 initial_args_decoded = false; |
6163 | 84 |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
85 if (nargin > 2) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
86 ## R, C, N? |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
87 arg1 = varargin{1}; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
88 arg2 = varargin{2}; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
89 arg3 = varargin{3}; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
90 if (isnumeric (arg1) && isscalar (arg1) && isnumeric (arg2) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
91 && isscalar (arg2) && isnumeric (arg3)) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
92 rows = arg1; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
93 cols = arg2; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
94 index = arg3; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
95 varargin(1:3)= []; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
96 initial_args_decoded = true; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
97 endif |
1540 | 98 endif |
99 | |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
100 if (! initial_args_decoded && nargin > 1) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
101 ## check for 'position', pos, ... |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
102 if (strcmpi (varargin{1}, "position")) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
103 arg = varargin{2}; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
104 if (isnumeric (arg) && numel (arg) == 4) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
105 pos = arg; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
106 varargin(1:2) = []; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
107 have_position = true; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
108 initial_args_decoded = true; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
109 else |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
110 error ("expecting position to be a 4-element numeric array"); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
111 endif |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
112 endif |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
113 endif |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
114 |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
115 if (! initial_args_decoded && nargin > 0) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
116 arg = varargin{1}; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
117 if (nargin == 1 && ishandle (arg)) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
118 ## Axes handle? |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
119 axes (arg); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
120 cf = get (0, "currentfigure"); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
121 set (cf, "nextplot", "add"); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
122 return; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
123 elseif (isscalar (arg) && arg >= 0) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
124 ## RCN? |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
125 index = rem (arg, 10); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
126 arg = (arg - index) / 10; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
127 cols = rem (arg, 10); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
128 arg = (arg - cols) / 10; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
129 rows = rem (arg, 10); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
130 varargin(1) = []; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
131 initial_args_decoded = true; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
132 else |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
133 error ("subplot: expecting axes handle or RCN argument"); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
134 endif |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
135 endif |
1540 | 136 |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
137 if (! initial_args_decoded) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
138 print_usage (); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
139 endif |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
140 |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
141 if (! have_position) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
142 cols = round (cols); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
143 rows = round (rows); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
144 index = round (index); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
145 |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
146 if (any (index < 1) || any (index > rows*cols)) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
147 error ("subplot: INDEX value must be greater than 1 and less than ROWS*COLS"); |
1540 | 148 endif |
149 | |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
150 if (cols < 1 || rows < 1 || index < 1) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
151 error ("subplot: COLS, ROWS, and INDEX must be be positive"); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
152 endif |
1540 | 153 endif |
154 | |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
155 nargs = numel (varargin); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
156 while (nargs > 0) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
157 arg = varargin{1}; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
158 if (strcmpi (arg, "align")) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
159 align_axes = true; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
160 elseif (strcmpi (arg, "replace")) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
161 replace_axes = true; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
162 else |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
163 break; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
164 endif |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
165 varargin(1) = []; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
166 nargs--; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
167 endwhile |
1540 | 168 |
12470
64ae43e0e1c0
subplot.m: Use new looseinset property introduced by changeset 12467.
Ben Abbott <bpabbott@mac.com>
parents:
12455
diff
changeset
|
169 axesunits = get (0, "defaultaxesunits"); |
12455
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
170 cf = gcf (); |
12470
64ae43e0e1c0
subplot.m: Use new looseinset property introduced by changeset 12467.
Ben Abbott <bpabbott@mac.com>
parents:
12455
diff
changeset
|
171 figureunits = get (cf, "units"); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
172 unwind_protect |
12470
64ae43e0e1c0
subplot.m: Use new looseinset property introduced by changeset 12467.
Ben Abbott <bpabbott@mac.com>
parents:
12455
diff
changeset
|
173 units = "normalized"; |
64ae43e0e1c0
subplot.m: Use new looseinset property introduced by changeset 12467.
Ben Abbott <bpabbott@mac.com>
parents:
12455
diff
changeset
|
174 set (0, "defaultaxesunits", units); |
12455
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
175 set (cf, "units", "pixels"); |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
176 |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
177 ## FIXME: At the moment we force gnuplot to use the aligned mode |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
178 ## which will set "activepositionproperty" to "position". |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
179 ## Τhis can yield to text overlap between labels and titles |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
180 ## see bug #31610 |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
181 if (strcmp (get (cf, "__graphics_toolkit__"), "gnuplot")) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
182 align_axes = true; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
183 endif |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
184 |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
185 if (! have_position) |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
186 pos = subplot_position (rows, cols, index, "position"); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
187 outerpos = subplot_position (rows, cols, index, "outerposition"); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
188 box = [pos(1:2), pos(1:2)+pos(3:4)]; |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
189 outerbox = [outerpos(1:2), outerpos(1:2)+outerpos(3:4)]; |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
190 looseinset = [box(1:2)-outerbox(1:2), outerbox(3:4)-box(3:4)]; |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
191 if (align_axes) |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
192 activepositionproperty = "position"; |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
193 else |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
194 activepositionproperty = "outerposition"; |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
195 endif |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
196 endif |
1540 | 197 |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
198 set (cf, "nextplot", "add"); |
1540 | 199 |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
200 found = false; |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
201 kids = get (cf, "children"); |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
202 for child = reshape (kids, 1, numel (kids)) |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
203 ## 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
|
204 ## 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
|
205 ## "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
|
206 ## with their corresponding axes). |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
207 if (! ishandle (child)) |
7086 | 208 continue; |
209 endif | |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
210 if (strcmp (get (child, "type"), "axes")) |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
211 ## 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
|
212 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
|
213 || strcmp (get (child, "tag"), "colorbar")) |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
214 continue; |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
215 endif |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
216 if (align_axes) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
217 objpos = get (child, "position"); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
218 else |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
219 objpos = get (child, "outerposition"); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
220 endif |
15498
623cce4577b3
Fix legend and subplot interaction (bug #37499)
Rik <rik@octave.org>
parents:
14327
diff
changeset
|
221 if (all (abs (objpos - pos) < eps) && ! replace_axes) |
10549 | 222 ## If the new axes are in exactly the same position as an |
223 ## existing axes object, use the existing axes. | |
224 found = true; | |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
225 hsubplot = child; |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
226 else |
10549 | 227 ## If the new axes overlap an old axes object, delete the old |
228 ## axes. | |
229 x0 = pos(1); | |
230 x1 = x0 + pos(3); | |
231 y0 = pos(2); | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
232 y1 = y0 + pos(4); |
10549 | 233 objx0 = objpos(1); |
234 objx1 = objx0 + objpos(3); | |
235 objy0 = objpos(2); | |
236 objy1 = objy0 + objpos(4); | |
237 if (! (x0 >= objx1 || x1 <= objx0 || y0 >= objy1 || y1 <= objy0)) | |
238 delete (child); | |
239 endif | |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
240 endif |
6178 | 241 endif |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
242 endfor |
1540 | 243 |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
244 if (found) |
17022
ddc62f0c7a35
Fix mistake from changeset 942d892524b3.
Stefan Mahr <dac922@gmx.de>
parents:
17012
diff
changeset
|
245 set (cf, "currentaxes", hsubplot); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
246 else |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
247 hsubplot = axes ("box", "off", |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
248 "position", pos, |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
249 "looseinset", looseinset, |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
250 "activepositionproperty", activepositionproperty, |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
251 varargin{:}); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
252 addproperty ("subplot_align", hsubplot, "boolean", true); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
253 addlistener (hsubplot, "position", @subplot_align); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
254 if (! align_axes) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
255 set (hsubplot, "subplot_align", false) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
256 subplot_align (hsubplot) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
257 endif |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
258 endif |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
259 |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
260 unwind_protect_cleanup |
12470
64ae43e0e1c0
subplot.m: Use new looseinset property introduced by changeset 12467.
Ben Abbott <bpabbott@mac.com>
parents:
12455
diff
changeset
|
261 set (0, "defaultaxesunits", axesunits); |
64ae43e0e1c0
subplot.m: Use new looseinset property introduced by changeset 12467.
Ben Abbott <bpabbott@mac.com>
parents:
12455
diff
changeset
|
262 set (cf, "units", figureunits); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
263 end_unwind_protect |
1540 | 264 |
6257 | 265 if (nargout > 0) |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
266 h = hsubplot; |
1540 | 267 endif |
268 | |
269 endfunction | |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
270 |
12470
64ae43e0e1c0
subplot.m: Use new looseinset property introduced by changeset 12467.
Ben Abbott <bpabbott@mac.com>
parents:
12455
diff
changeset
|
271 function pos = subplot_position (rows, cols, index, position_property) |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
272 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11305
diff
changeset
|
273 if (rows == 1 && cols == 1) |
12455
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
274 ## Trivial result for subplot (1,1,1) |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
275 if (strcmpi (position_property, "position")) |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
276 pos = get (0, "defaultaxesposition"); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
277 else |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
278 pos = get (0, "defaultaxesouterposition"); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
279 endif |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
280 return |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
281 endif |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
282 |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
283 if (strcmp (position_property, "outerposition") |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
284 || strcmp (position_property, "outerpositiontight")) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
285 margins.left = 0.05; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
286 margins.bottom = 0.05; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
287 margins.right = 0.05; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
288 margins.top = 0.05; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
289 if (strcmp (position_property, "outerpositiontight")) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
290 margins.column = 0.; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
291 margins.row = 0.; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
292 else |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
293 margins.column = 0.04 / cols; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
294 margins.row = 0.04 / rows; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
295 endif |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
296 width = 1 - margins.left - margins.right - (cols-1)*margins.column; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
297 width = width / cols; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
298 height = 1 - margins.top - margins.bottom - (rows-1)*margins.row; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
299 height = height / rows; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
300 else |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
301 defaultaxesposition = get (0, "defaultaxesposition"); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
302 |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
303 ## The outer margins surrounding all subplot "positions" are independent |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
304 ## of the number of rows and/or columns |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
305 margins.left = defaultaxesposition(1); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
306 margins.bottom = defaultaxesposition(2); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
307 margins.right = 1.0 - margins.left - defaultaxesposition(3); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
308 margins.top = 1.0 - margins.bottom - defaultaxesposition(4); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
309 |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
310 ## Fit from Matlab experiments |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
311 pc = 1 ./ [0.1860, (margins.left + margins.right - 1)]; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
312 margins.column = 1 ./ polyval (pc , cols); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
313 pr = 1 ./ [0.2282, (margins.top + margins.bottom - 1)]; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
314 margins.row = 1 ./ polyval (pr , rows); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
315 |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
316 ## Calculate the width/height of the subplot axes "position". |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
317 ## This is also consistent with Matlab |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
318 width = 1 - margins.left - margins.right - (cols-1)*margins.column; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
319 width = width / cols; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
320 height = 1 - margins.top - margins.bottom - (rows-1)*margins.row; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
321 height = height / rows; |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
322 endif |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
323 |
12455
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
324 ## Index offsets from the lower left subplot |
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
325 yi = fix ((index(:)-1)/cols); |
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
326 xi = index(:) - yi*cols - 1; |
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
327 yi = (rows - 1) - yi; |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
328 |
12455
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
329 ## Lower left corner of the subplot, i.e. position(1:2) |
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
330 x0 = xi .* (width + margins.column) + margins.left; |
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
331 y0 = yi .* (height + margins.row) + margins.bottom; |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
332 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
333 if (numel (x0) > 1) |
12455
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
334 ## subplot (row, col, m:n) |
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
335 x1 = max (x0(:)) + width; |
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
336 y1 = max (y0(:)) + height; |
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
337 x0 = min (x0(:)); |
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
338 y0 = min (y0(:)); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
339 pos = [x0, y0, x1-x0, y1-y0]; |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
340 else |
12455
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
341 ## subplot (row, col, num) |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
342 pos = [x0, y0, width, height]; |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
343 endif |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
344 |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
345 endfunction |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
346 |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
347 function subplot_align (h, varargin) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
348 persistent updating = false |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
349 if (! updating) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
350 unwind_protect |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
351 updating = true; |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
352 hfig = ancestor (h, "figure"); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
353 hsubplots = findall (hfig, 'type', 'axes', 'subplot_align', 'off'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
354 if (! isempty (hsubplots)) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
355 tightinset = get (hsubplots, 'tightinset'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
356 if (iscell (tightinset)) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
357 tightinset = max (cell2mat (tightinset)); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
358 endif |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
359 looseinset = get (hsubplots, 'looseinset'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
360 if (iscell (looseinset)) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
361 looseinset = max (cell2mat (looseinset)); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
362 endif |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
363 looseinset = max (tightinset, looseinset); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
364 set (hsubplots, 'looseinset', looseinset); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
365 endif |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
366 unwind_protect_cleanup |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
367 updating = false; |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
368 end_unwind_protect |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
369 endif |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
370 endfunction |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14335
diff
changeset
|
371 |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
372 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
373 %! clf; |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
374 %! r = 3; |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
375 %! c = 3; |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
376 %! fmt = {'horizontalalignment', 'center', 'verticalalignment', 'middle'}; |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
377 %! for n = 1 : r*c |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
378 %! subplot (r, c, n); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
379 %! xlabel (sprintf ('xlabel #%d', n)); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
380 %! ylabel (sprintf ('ylabel #%d', n)); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
381 %! title (sprintf ('title #%d', n)); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
382 %! text (0.5, 0.5, sprintf ('subplot(%d,%d,%d)', r, c, n), fmt{:}); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
383 %! axis ([0 1 0 1]); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
384 %! end |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
385 %! subplot (r, c, 1:3); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
386 %! xlabel (sprintf ('xlabel #%d:%d', 1, 3)); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
387 %! ylabel (sprintf ('ylabel #%d:%d', 1, 3)); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
388 %! title (sprintf ('title #%d:%d', 1, 3)); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
389 %! text (0.5, 0.5, sprintf ('subplot(%d,%d,%d:%d)', r, c, 1, 3), fmt{:}); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
390 %! axis ([0 1 0 1]); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
391 |
11305
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
392 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
393 %! clf; |
11305
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
394 %! x = 0:1; |
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
395 %! for n = 1:4 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14335
diff
changeset
|
396 %! subplot (2,2,n, 'align'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
397 %! plot (x, x); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
398 %! xlabel (sprintf ('xlabel (2,2,%d)', n)); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
399 %! ylabel (sprintf ('ylabel (2,2,%d)', n)); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
400 %! title (sprintf ('title (2,2,%d)', n)); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
401 %! end |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14335
diff
changeset
|
402 %! subplot (1,2,1, 'align'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
403 %! plot (x, x); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
404 %! xlabel ('xlabel (1,2,1)'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
405 %! ylabel ('ylabel (1,2,1)'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
406 %! title ('title (1,2,1)'); |
11305
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
407 |
16975 | 408 %!demo |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
409 %! clf; |
16975 | 410 %! x = 0:10; |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
411 %! ax(1) = subplot (221); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
412 %! set (ax(1), 'tag', '1'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
413 %! plot (x, rand (3, 11)) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
414 %! title ('x & y labels & ticklabels'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
415 %! xlabel xlabel |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
416 %! ylabel ylabel |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
417 %! ax(2) = subplot (222); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
418 %! set (ax(2), 'tag', '2'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
419 %! plot (x, rand (3, 11)) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
420 %! title ('no labels'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
421 %! axis ('nolabel','tic') |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
422 %! ax(3) = subplot (223); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
423 %! set (ax(3), 'tag', '3'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
424 %! plot (x, rand (3, 11)) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
425 %! title ('no labels'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
426 %! axis ('nolabel','tic') |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
427 %! ax(4) = subplot (224); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
428 %! set (ax(4), 'tag', '4'); |
16975 | 429 %! plot (x, rand (3, 11)) |
430 %! title ('x & y labels & ticklabels'); | |
431 %! xlabel xlabel | |
432 %! ylabel ylabel | |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
433 |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
434 %!demo |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
435 %! x = 0:10; |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
436 %! subplot (221); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
437 %! plot (x, rand (3, 11)) |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
438 %! ylim ([0, 1]); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
439 %! text (0.5, 0.5, '{x,y}labels & {x,y}ticklabels', ... |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
440 %! 'horizontalalignment', 'center', ... |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
441 %! 'units', 'normalized'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
442 %! xlabel xlabel |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
443 %! ylabel ylabel |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
444 %! title title |
16975 | 445 %! subplot (222); |
446 %! plot (x, rand (3, 11)) | |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
447 %! axis ('labely'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
448 %! ylabel ylabel |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
449 %! text (0.5, 0.5, 'no xlabels, xticklabels', ... |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
450 %! 'horizontalalignment', 'center', ... |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
451 %! 'units', 'normalized'); |
16975 | 452 %! subplot (223); |
453 %! plot (x, rand (3, 11)) | |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
454 %! axis ('labelx'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
455 %! text (0.5, 0.5, 'no ylabels, yticklabels', ... |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
456 %! 'horizontalalignment', 'center', ... |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
457 %! 'units', 'normalized'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
458 %! xlabel xlabel |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
459 %! title title |
16975 | 460 %! subplot (224); |
461 %! plot (x, rand (3, 11)) | |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
462 %! axis ('nolabel','tic'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
463 %! text (0.5, 0.5, 'no {x,y}labels, {x,y}ticklabels', ... |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
464 %! 'horizontalalignment', 'center', ... |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
465 %! 'units', 'normalized'); |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
466 |