Mercurial > octave-libtiff
annotate scripts/plot/util/subplot.m @ 30875:5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
For new users of Octave it is best to show explicit calling forms
in the documentation and to show a return argument when it exists.
* bp-table.cc, shift.m, accumarray.m, accumdim.m, bincoeff.m, bitcmp.m,
bitget.m, bitset.m, blkdiag.m, celldisp.m, cplxpair.m, dblquad.m, flip.m,
fliplr.m, flipud.m, idivide.m, int2str.m, interpft.m, logspace.m, num2str.m,
polyarea.m, postpad.m, prepad.m, randi.m, repmat.m, rng.m, rot90.m, rotdim.m,
structfun.m, triplequad.m, uibuttongroup.m, uicontrol.m, uipanel.m,
uipushtool.m, uitoggletool.m, uitoolbar.m, waitforbuttonpress.m, help.m,
__additional_help_message__.m, hsv.m, im2double.m, im2frame.m, javachk.m,
usejava.m, argnames.m, char.m, formula.m, inline.m, __vectorize__.m, findstr.m,
flipdim.m, strmatch.m, vectorize.m, commutation_matrix.m, cond.m, cross.m,
duplication_matrix.m, expm.m, orth.m, rank.m, rref.m, trace.m, vech.m, cast.m,
compare_versions.m, delete.m, dir.m, fileattrib.m, grabcode.m, gunzip.m,
inputname.m, license.m, list_primes.m, ls.m, mexext.m, movefile.m,
namelengthmax.m, nargoutchk.m, nthargout.m, substruct.m, swapbytes.m, ver.m,
verLessThan.m, what.m, fminunc.m, fsolve.m, fzero.m, optimget.m, __fdjac__.m,
matlabroot.m, savepath.m, campos.m, camroll.m, camtarget.m, camup.m, camva.m,
camzoom.m, clabel.m, diffuse.m, legend.m, orient.m, rticks.m, specular.m,
thetaticks.m, xlim.m, xtickangle.m, xticklabels.m, xticks.m, ylim.m,
ytickangle.m, yticklabels.m, yticks.m, zlim.m, ztickangle.m, zticklabels.m,
zticks.m, ellipsoid.m, isocolors.m, isonormals.m, stairs.m, surfnorm.m,
__actual_axis_position__.m, __pltopt__.m, close.m, graphics_toolkit.m, pan.m,
print.m, printd.m, __ghostscript__.m, __gnuplot_print__.m, __opengl_print__.m,
rotate3d.m, subplot.m, zoom.m, compan.m, conv.m, poly.m, polyaffine.m,
polyder.m, polyint.m, polyout.m, polyreduce.m, polyvalm.m, roots.m, prefdir.m,
prefsfile.m, profexplore.m, profexport.m, profshow.m, powerset.m, unique.m,
arch_rnd.m, arma_rnd.m, autoreg_matrix.m, bartlett.m, blackman.m, detrend.m,
durbinlevinson.m, fftconv.m, fftfilt.m, fftshift.m, fractdiff.m, hamming.m,
hanning.m, hurst.m, ifftshift.m, rectangle_lw.m, rectangle_sw.m, triangle_lw.m,
sinc.m, sinetone.m, sinewave.m, spectral_adf.m, spectral_xdf.m, spencer.m,
ilu.m, __sprand__.m, sprand.m, sprandn.m, sprandsym.m, treelayout.m, beta.m,
betainc.m, betaincinv.m, betaln.m, cosint.m, expint.m, factorial.m, gammainc.m,
gammaincinv.m, lcm.m, nthroot.m, perms.m, reallog.m, realpow.m, realsqrt.m,
sinint.m, hadamard.m, hankel.m, hilb.m, invhilb.m, magic.m, pascal.m, rosser.m,
toeplitz.m, vander.m, wilkinson.m, center.m, corr.m, cov.m, discrete_cdf.m,
discrete_inv.m, discrete_pdf.m, discrete_rnd.m, empirical_cdf.m,
empirical_inv.m, empirical_pdf.m, empirical_rnd.m, kendall.m, kurtosis.m,
mad.m, mean.m, meansq.m, median.m, mode.m, moment.m, range.m, ranks.m,
run_count.m, skewness.m, spearman.m, statistics.m, std.m, base2dec.m,
bin2dec.m, blanks.m, cstrcat.m, deblank.m, dec2base.m, dec2bin.m, dec2hex.m,
hex2dec.m, index.m, regexptranslate.m, rindex.m, strcat.m, strjust.m,
strtrim.m, strtrunc.m, substr.m, untabify.m, __have_feature__.m,
__prog_output_assert__.m, __run_test_suite__.m, example.m, fail.m, asctime.m,
calendar.m, ctime.m, date.m, etime.m:
Add return arguments to @deftypefn macros where they were missing. Rename
variables in functions (particularly generic "retval") to match documentation.
Rename some return variables for (hopefully) better clarity (e.g., 'ax' to 'hax'
to indicate it is a graphics handle to an axes object).
author | Rik <rik@octave.org> |
---|---|
date | Wed, 30 Mar 2022 20:40:27 -0700 |
parents | 796f54d4ddbf |
children | bb9c7512e090 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30326
diff
changeset
|
3 ## Copyright (C) 1995-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
2313 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24432
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
2313 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24432
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
2313 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
2313 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24432
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
1540 | 25 |
3368 | 26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20711
diff
changeset
|
27 ## @deftypefn {} {} subplot (@var{rows}, @var{cols}, @var{index}) |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
28 ## @deftypefnx {} {} subplot (@var{rows}, @var{cols}, @var{index}, @var{hax}) |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20711
diff
changeset
|
29 ## @deftypefnx {} {} subplot (@var{rcn}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20711
diff
changeset
|
30 ## @deftypefnx {} {} subplot (@var{hax}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20711
diff
changeset
|
31 ## @deftypefnx {} {} subplot (@dots{}, "align") |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20711
diff
changeset
|
32 ## @deftypefnx {} {} subplot (@dots{}, "replace") |
28177
bc829338e353
doc: Clarify behavior of "subplot".
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
33 ## @deftypefnx {} {} subplot ("position", @var{pos}) |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20711
diff
changeset
|
34 ## @deftypefnx {} {} subplot (@dots{}, @var{prop}, @var{val}, @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20711
diff
changeset
|
35 ## @deftypefnx {} {@var{hax} =} subplot (@dots{}) |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
36 ## Set up a plot grid with @var{rows} by @var{cols} subwindows and set the |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
37 ## current axes for plotting (@code{gca}) to the location given by @var{index}. |
3426 | 38 ## |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
39 ## If an axes handle @var{hax} is provided after the (@var{rows}, @var{cols}, |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
40 ## @var{index}) arguments, the corresponding axes is turned into a |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
41 ## subplot. |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
42 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
43 ## If only one numeric argument is supplied, then it must be a three digit |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
44 ## value specifying the number of rows in digit 1, the number of columns in |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
45 ## digit 2, and the plot index in digit 3. |
17085
d3ebc3f9bdbf
doc update for grid and subplot
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
17022
diff
changeset
|
46 ## |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
47 ## The plot index runs row-wise; First, all columns in a row are numbered |
3368 | 48 ## and then the next row is filled. |
3426 | 49 ## |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
50 ## For example, a plot with 2x3 grid will have plot indices running as follows: |
3368 | 51 ## @tex |
52 ## \vskip 10pt | |
53 ## \hfil\vbox{\offinterlineskip\hrule | |
54 ## \halign{\vrule#&&\qquad\hfil#\hfil\qquad\vrule\cr | |
7107 | 55 ## height13pt&1&2&3\cr height12pt&&&\cr\noalign{\hrule} |
56 ## height13pt&4&5&6\cr height12pt&&&\cr\noalign{\hrule}}} | |
3368 | 57 ## \hfil |
58 ## \vskip 10pt | |
59 ## @end tex | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8350
diff
changeset
|
60 ## @ifnottex |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
61 ## |
8350
0e3a92a8683c
fix texi bug in subplot.m
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8232
diff
changeset
|
62 ## @example |
3368 | 63 ## @group |
7040 | 64 ## +-----+-----+-----+ |
65 ## | 1 | 2 | 3 | | |
66 ## +-----+-----+-----+ | |
67 ## | 4 | 5 | 6 | | |
68 ## +-----+-----+-----+ | |
8350
0e3a92a8683c
fix texi bug in subplot.m
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8232
diff
changeset
|
69 ## @end group |
6257 | 70 ## @end example |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
71 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
72 ## @end ifnottex |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
73 ## |
24431
0c6cedafc71e
doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
74 ## @var{index} may also be a vector. In this case, the new axes will enclose |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
75 ## the grid locations specified. The first demo illustrates this: |
12476
070214996fba
subplot.m: Document using INDEX as a vector.
Ben Abbott <bpabbott@mac.com>
parents:
12470
diff
changeset
|
76 ## |
070214996fba
subplot.m: Document using INDEX as a vector.
Ben Abbott <bpabbott@mac.com>
parents:
12470
diff
changeset
|
77 ## @example |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
78 ## demo ("subplot", 1) |
12476
070214996fba
subplot.m: Document using INDEX as a vector.
Ben Abbott <bpabbott@mac.com>
parents:
12470
diff
changeset
|
79 ## @end example |
070214996fba
subplot.m: Document using INDEX as a vector.
Ben Abbott <bpabbott@mac.com>
parents:
12470
diff
changeset
|
80 ## |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
81 ## The index of the subplot to make active may also be specified by its axes |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
82 ## handle, @var{hax}, returned from a previous @code{subplot} command. |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
83 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
84 ## If the option @qcode{"align"} is given then the plot boxes of the subwindows |
24431
0c6cedafc71e
doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
85 ## will align, but this may leave no room for axes tick marks or labels. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17095
diff
changeset
|
86 ## |
24431
0c6cedafc71e
doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
87 ## If the option @qcode{"replace"} is given then the subplot axes will be |
0c6cedafc71e
doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
88 ## reset, rather than just switching the current axes for plotting to the |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
89 ## requested subplot. |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
90 ## |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
91 ## The @qcode{"position"} property can be used to exactly position the subplot |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
92 ## axes within the current figure. The option @var{pos} is a 4-element vector |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
93 ## [x, y, width, height] that determines the location and size of the axes. |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
94 ## The values in @var{pos} are normalized in the range [0,1]. |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
95 ## |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
96 ## Any property/value pairs are passed directly to the underlying axes object. |
28733
9342688e86b4
Updated property references for text and graphics functions (bug #50247)
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
28177
diff
changeset
|
97 ## The full list of properties is documented at @ref{Axes Properties}. |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
98 ## |
28177
bc829338e353
doc: Clarify behavior of "subplot".
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
99 ## Any previously existing axes that would be (partly) covered by the newly |
bc829338e353
doc: Clarify behavior of "subplot".
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
100 ## created axes are deleted. |
bc829338e353
doc: Clarify behavior of "subplot".
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
101 ## |
24431
0c6cedafc71e
doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
102 ## If the output @var{hax} is requested, subplot returns the axes handle for |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
103 ## the subplot. This is useful for modifying the properties of a subplot |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
104 ## using @code{set}. |
29004
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
105 ## |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
106 ## Under some circumstances, @code{subplot} might not be able to identify axes |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
107 ## that it could re-use and might replace them. If @code{subplot} axes |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
108 ## should be referenced repeatedly, consider creating and storing their axes |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
109 ## handles beforehand instead of calling @code{subplot} repeatedly for the same |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
110 ## position. |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
111 ## |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
112 ## Example: |
29668
f17b1f0141ed
doc: Grammarcheck documentation ahead of 6.3 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
113 ## |
29004
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
114 ## @example |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
115 ## @group |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
116 ## x = 1:10; |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
117 ## y = rand (16, 10); |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
118 ## for i_plot = 1:4 |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
119 ## hax(i_plot) = subplot (2, 2, i_plot); |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
120 ## hold (hax(i_plot), "on"); |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
121 ## grid (hax(i_plot), "on"); |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
122 ## endfor |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
123 ## for i_loop = 1:2 |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
124 ## for i_plot = 1:4 |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
125 ## iy = (i_loop - 1)*4 + i_plot; |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
126 ## plotyy (hax(i_plot), x,y(iy,:), x,y(iy+1,:)); |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
127 ## endfor |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
128 ## endfor |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
129 ## @end group |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
130 ## @end example |
e44e3c2b7eea
doc: Improve documentation for subplot in conjunction with plotyy (bug #58566).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28786
diff
changeset
|
131 ## |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
132 ## @seealso{axes, plot, gca, set} |
3368 | 133 ## @end deftypefn |
1540 | 134 |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
135 function hax = subplot (varargin) |
11305
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
136 |
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
137 align_axes = false; |
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
138 replace_axes = false; |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
139 have_position = false; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
140 initial_args_decoded = false; |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
141 make_subplot = false; |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
142 hsubplot = []; |
6163 | 143 |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
144 if (nargin >= 3) |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
145 ## R, C, N? |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
146 arg1 = varargin{1}; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
147 arg2 = varargin{2}; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
148 arg3 = varargin{3}; |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
149 if ( isnumeric (arg1) && isscalar (arg1) |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
150 && isnumeric (arg2) && isscalar (arg2) |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
151 && isnumeric (arg3)) |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
152 rows = arg1; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
153 cols = arg2; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
154 index = arg3; |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
155 if (nargin > 3 && isaxes (varargin{4})) |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
156 make_subplot = true; |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
157 hsubplot = varargin{4}; |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
158 varargin(1:4) = []; |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
159 else |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
160 varargin(1:3) = []; |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
161 endif |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
162 initial_args_decoded = true; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
163 endif |
1540 | 164 endif |
165 | |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
166 if (! initial_args_decoded && nargin > 1) |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
167 ## check for "position", pos, ... |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
168 if (strcmpi (varargin{1}, "position")) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
169 arg = varargin{2}; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
170 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
|
171 pos = arg; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
172 varargin(1:2) = []; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
173 have_position = true; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
174 initial_args_decoded = true; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
175 else |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
176 error ("subplot: POSITION must be a 4-element numeric array"); |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
177 endif |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
178 endif |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
179 endif |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17860
diff
changeset
|
180 |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
181 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
|
182 arg = varargin{1}; |
17303
8520c264619c
subplot.m: Use isaxes() function instead of ishandle() to check for axes.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
183 if (nargin == 1 && isaxes (arg)) |
8520c264619c
subplot.m: Use isaxes() function instead of ishandle() to check for axes.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
184 ## Axes handle |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
185 axes (arg); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
186 cf = get (0, "currentfigure"); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
187 set (cf, "nextplot", "add"); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
188 return; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
189 elseif (isscalar (arg) && arg >= 0) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
190 ## RCN? |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
191 index = rem (arg, 10); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
192 arg = (arg - index) / 10; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
193 cols = rem (arg, 10); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
194 arg = (arg - cols) / 10; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
195 rows = rem (arg, 10); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
196 varargin(1) = []; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
197 initial_args_decoded = true; |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
198 else |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
199 error ("subplot: invalid axes handle or RCN argument"); |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
200 endif |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
201 endif |
1540 | 202 |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
203 if (! initial_args_decoded) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
204 print_usage (); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
205 endif |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
206 |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
207 if (! have_position) |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
208 cols = round (cols); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
209 rows = round (rows); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
210 index = round (index); |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
211 |
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
212 if (any (index < 1) || any (index > rows*cols)) |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
213 error ("subplot: INDEX value must be >= 1 and <= ROWS*COLS"); |
1540 | 214 endif |
215 | |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
216 if (rows < 1 || cols < 1 || index < 1) |
22173
8de49f15e182
doc: Fix "doubled words" typos (\b(\w+)\s+\1\b)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
21758
diff
changeset
|
217 error ("subplot: ROWS, COLS, and INDEX must be positive"); |
13794
5b395217ccb9
improve argument parsing for subplot, handle 'position' argument
John W. Eaton <jwe@octave.org>
parents:
12685
diff
changeset
|
218 endif |
1540 | 219 endif |
220 | |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
221 ## Process "align" and "replace" options |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
222 idx = strcmpi (varargin, "align"); |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
223 if (any (idx)) |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
224 align_axes = true; |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
225 varargin(idx) = []; |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
226 endif |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
227 |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
228 idx = strcmpi (varargin, "replace"); |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
229 if (any (idx)) |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
230 replace_axes = true; |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
231 varargin(idx) = []; |
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
232 endif |
1540 | 233 |
12470
64ae43e0e1c0
subplot.m: Use new looseinset property introduced by changeset 12467.
Ben Abbott <bpabbott@mac.com>
parents:
12455
diff
changeset
|
234 axesunits = get (0, "defaultaxesunits"); |
12455
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
235 cf = gcf (); |
12470
64ae43e0e1c0
subplot.m: Use new looseinset property introduced by changeset 12467.
Ben Abbott <bpabbott@mac.com>
parents:
12455
diff
changeset
|
236 figureunits = get (cf, "units"); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
237 unwind_protect |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
238 set (0, "defaultaxesunits", "normalized"); |
12455
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
239 set (cf, "units", "pixels"); |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
240 |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
241 ## FIXME: At the moment we force gnuplot to use the aligned mode |
28310
1379ebcb00c3
Replace uses of axes property "activepositionproperty" by "positionconstraint" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28177
diff
changeset
|
242 ## which will set "positionconstraint" to "innerposition". |
17860
93edd282a2bc
subplot.m: Matlab compatibility when "position" given (bug #40480).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
243 ## This can yield to text overlap between labels and titles. |
93edd282a2bc
subplot.m: Matlab compatibility when "position" given (bug #40480).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
244 ## See bug #31610. |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
245 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
|
246 align_axes = true; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
247 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
248 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
249 if (! have_position) |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
250 ## Subplots that cover more that one base subplot are not updated |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
251 align_axes = (align_axes || (! isscalar (index))); |
17860
93edd282a2bc
subplot.m: Matlab compatibility when "position" given (bug #40480).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
252 ## Normal case where subplot indices have been given |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
253 [pos, opos, li] = subplot_position (cf, rows, cols, index); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
254 else |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
255 ## Position is specified by the user. |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
256 li = zeros (1,4); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
257 align_axes = true; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
258 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
259 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
260 set (cf, "nextplot", "add"); |
17860
93edd282a2bc
subplot.m: Matlab compatibility when "position" given (bug #40480).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
261 |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
262 if (! make_subplot) |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
263 found = false; |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
264 kids = get (cf, "children"); |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
265 for child = kids(:)' |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
266 ## Check whether this child is still valid; this might not be the |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
267 ## case anymore due to the deletion of previous children (due to |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
268 ## "deletefcn" callback or for legends/colorbars that are deleted |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
269 ## with their corresponding axes). |
24423
1d52db450db4
Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents:
24188
diff
changeset
|
270 if (! ishghandle (child)) |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
271 continue; |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
272 endif |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
273 if (strcmp (get (child, "type"), "axes")) |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
274 ## Skip legend and colorbar objects. |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
275 if (any (strcmp (get (child, "tag"), {"legend", "colorbar"}))) |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
276 continue; |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
277 endif |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
278 |
28786
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
279 if (! replace_axes) |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
280 if (isappdata (child, "__subplotposition__")) |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
281 objpos = getappdata (child, "__subplotposition__"); |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
282 else |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
283 objpos = get (child, "position"); |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
284 endif |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
285 if (all (abs (objpos - pos) < eps)) |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
286 ## If the new axes are in exactly the same position |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
287 ## as an existing axes object, or if they share the same |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
288 ## appdata "__subplotposition__", use the existing axes. |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
289 found = true; |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
290 hsubplot = child; |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
291 else |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
292 ## Check if this axes is a subplot with the same layout and |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
293 ## index as the requested one |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
294 rcn = getappdata (child, "__subplotrcn__"); |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
295 if (all (size (rcn) == [1 3]) |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
296 && rcn{1} == rows && rcn{2} == cols && all (rcn{3} == index)) |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
297 found = true; |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
298 hsubplot = child; |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
299 endif |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
300 endif |
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
301 endif |
28784
9d7f90354b4f
subplot.m: Use layout and index to search existing axes (bug #59076)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
28733
diff
changeset
|
302 |
28786
396d3e1df78b
subplot.m: Use position and layout info to identify existing axes (bug #59076).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28784
diff
changeset
|
303 if (! found) |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
304 ## If the new axes overlap an old axes object, delete the old axes. |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
305 objpos = get (child, "position"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
306 |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
307 x0 = pos(1); |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
308 x1 = x0 + pos(3); |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
309 y0 = pos(2); |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
310 y1 = y0 + pos(4); |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
311 objx0 = objpos(1); |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
312 objx1 = objx0 + objpos(3); |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
313 objy0 = objpos(2); |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
314 objy1 = objy0 + objpos(4); |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
315 if (! (x0 >= objx1 || x1 <= objx0 || y0 >= objy1 || y1 <= objy0)) |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
316 delete (child); |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
317 endif |
10549 | 318 endif |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
319 endif |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
320 endfor |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
321 else |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
322 found = true; |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
323 endif |
1540 | 324 |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
325 if (found && ! make_subplot) |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
326 ## Switch to existing subplot and set requested properties |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
327 set (cf, "currentaxes", hsubplot); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
328 if (! isempty (varargin)) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
329 set (hsubplot, varargin{:}); |
17860
93edd282a2bc
subplot.m: Matlab compatibility when "position" given (bug #40480).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
330 endif |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
331 else |
28310
1379ebcb00c3
Replace uses of axes property "activepositionproperty" by "positionconstraint" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28177
diff
changeset
|
332 pval = [{"positionconstraint", "innerposition", ... |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
333 "position", pos, "looseinset", li} varargin]; |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
334 if (! make_subplot) |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
335 hsubplot = axes (pval{:}); |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
336 else |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
337 set (hsubplot, pval{:}) |
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
338 endif |
17860
93edd282a2bc
subplot.m: Matlab compatibility when "position" given (bug #40480).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
339 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
340 if (! align_axes) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
341 ## base position (no ticks, no annotation, no cumbersome neighbor) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
342 setappdata (hsubplot, "__subplotposition__", pos); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
343 ## max outerposition |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
344 setappdata (hsubplot, "__subplotouterposition__", opos); |
23930
174b6afa7e7f
Fix regression in subplot alignment (bugs #51717 and #51731)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23220
diff
changeset
|
345 setappdata (hsubplot, "__subplotrcn__", {rows, cols, index}); |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
346 addlistener (hsubplot, "outerposition", @subplot_align); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
347 addlistener (hsubplot, "xaxislocation", @subplot_align); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
348 addlistener (hsubplot, "yaxislocation", @subplot_align); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
349 addlistener (hsubplot, "position", {@subplot_align, true}); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
350 subplot_align (hsubplot); |
17860
93edd282a2bc
subplot.m: Matlab compatibility when "position" given (bug #40480).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
351 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
352 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
353 endif |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
354 unwind_protect_cleanup |
12470
64ae43e0e1c0
subplot.m: Use new looseinset property introduced by changeset 12467.
Ben Abbott <bpabbott@mac.com>
parents:
12455
diff
changeset
|
355 set (0, "defaultaxesunits", axesunits); |
64ae43e0e1c0
subplot.m: Use new looseinset property introduced by changeset 12467.
Ben Abbott <bpabbott@mac.com>
parents:
12455
diff
changeset
|
356 set (cf, "units", figureunits); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
357 end_unwind_protect |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
358 |
6257 | 359 if (nargout > 0) |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
360 hax = hsubplot; |
1540 | 361 endif |
362 | |
363 endfunction | |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
364 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
365 function [pos, opos, li] = subplot_position (hf, nrows, ncols, idx) |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
366 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
367 if (nrows == 1 && ncols == 1) |
12455
7b67bbf9dbbb
subplot.m: Decrease spacing between subplots rows / columns.
Ben Abbott <bpabbott@mac.com>
parents:
12132
diff
changeset
|
368 ## Trivial result for subplot (1,1,1) |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
369 pos = get (0, "defaultaxesposition"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
370 opos = get (0, "defaultaxesouterposition"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
371 li = get (0, "defaultaxeslooseinset"); |
17312
088d014a7fe2
Use semicolon after "return" statement in core m-files.
Rik <rik@octave.org>
parents:
17303
diff
changeset
|
372 return; |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
373 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
374 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
375 ## Row/Column inside the axes array |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
376 row = ceil (idx / ncols); |
30326
cd7c824f3f22
eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents:
29670
diff
changeset
|
377 col = idx - (row - 1) * ncols; |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
378 row = [min(row) max(row)]; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
379 col = [min(col) max(col)]; |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
380 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
381 ## Minimal margins around subplots defined in points |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
382 fig_units = get (hf, "units"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
383 set (hf, "units", "points"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
384 pts_size = get (gcf, "position")(3:4); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
385 xbasemargin = 6 / pts_size(1); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
386 ybasemargin = 6 / pts_size(2); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
387 |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
388 ## Column/row separation |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
389 margin.column = .2 / ncols + 2 * xbasemargin; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
390 margin.row = .2 / nrows + 2 * ybasemargin; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
391 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
392 set (hf, "units", fig_units); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
393 margin.left = xbasemargin; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
394 margin.right = xbasemargin; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
395 margin.bottom = ybasemargin; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
396 margin.top = ybasemargin; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
397 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
398 ## Boundary axes have default margins |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
399 borders = get (0, "defaultaxesposition"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
400 if (col(1) == 1) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
401 margin.left = borders(1); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
402 else |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
403 margin.left = margin.column - margin.right; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
404 endif |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
405 if (col(2) == ncols) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
406 margin.right = 1 - borders(1) - borders(3); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
407 endif |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
408 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
409 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
410 if (row(2) == nrows) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
411 margin.bottom = borders(2); |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12575
diff
changeset
|
412 else |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
413 margin.bottom = margin.row - margin.top; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
414 endif |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
415 if (row(1) == 1) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
416 margin.top = 1 - borders(2) - borders(4); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
417 endif |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
418 |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
419 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
420 ## Compute base width and height |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
421 width = (borders(3) - (ncols - 1) * margin.column) / ncols; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
422 height = (borders(4) - (nrows - 1) * margin.row) /nrows; |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
423 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
424 ## Position, outerposition and looseinset |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
425 x0 = borders(1) + (col(1) - 1) * (width + margin.column); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
426 y0 = borders(2) + (nrows - row(2)) * (height + margin.row); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
427 width += diff (col) * (width + margin.column); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
428 height += diff (row) * (height + margin.row); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
429 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
430 pos = [x0 y0 width height]; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
431 opos = [(x0 - margin.left), (y0 - margin.bottom), ... |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
432 (width + margin.left + margin.right), ... |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
433 (height + margin.bottom + margin.top)]; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
434 li = [margin.left, margin.bottom, margin.right, margin.top]; |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
435 |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
436 endfunction |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
437 |
28595
4deb794d85e2
Resolve further number of argument mismatch in graphics callbacks (bug #58821)
Rik <rik@octave.org>
parents:
28310
diff
changeset
|
438 function subplot_align (h, ~, rmupdate = false) |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
439 persistent updating = false; |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21751
diff
changeset
|
440 |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
441 if (! updating) |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
442 if (rmupdate) |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
443 ## The "position" property has been changed from outside this routine. |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
444 ## Don't update anymore. |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
445 if (isappdata (h, "__subplotposition__")) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
446 rmappdata (h, "__subplotposition__"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
447 rmappdata (h, "__subplotouterposition__"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
448 endif |
28917
72d57dbcc305
maint: Add semicolon after break and return keywords.
Rik <rik@octave.org>
parents:
28787
diff
changeset
|
449 return; |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
450 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
451 |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
452 unwind_protect |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
453 updating = true; |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
454 hf = ancestor (h, "figure"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
455 children = get (hf, "children"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
456 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
457 ## Base position of the subplot |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
458 pos = getappdata (children, "__subplotposition__"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
459 |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
460 if (iscell (pos)) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
461 do_align = ! cellfun (@isempty, pos); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
462 pos = cell2mat (pos(do_align)); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
463 else |
28917
72d57dbcc305
maint: Add semicolon after break and return keywords.
Rik <rik@octave.org>
parents:
28787
diff
changeset
|
464 return; |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
465 endif |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
466 hsubplots = children(do_align); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
467 |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
468 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
469 ## There may be mixed subplot series (e.g., 2-by-6 and 1-by-6) in |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
470 ## the same figure. Only subplots that have the same width and |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
471 ## height as this one are updated. |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
472 if (any (h == hsubplots)) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
473 width = pos(h == hsubplots, 3); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
474 height = pos(h == hsubplots, 4); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
475 do_align = (pos(:,3) == width) & (pos(:,4) == height); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
476 hsubplots(! do_align) = []; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
477 pos(! do_align,:) = []; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
478 else |
28917
72d57dbcc305
maint: Add semicolon after break and return keywords.
Rik <rik@octave.org>
parents:
28787
diff
changeset
|
479 return; |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
480 endif |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
481 |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
482 ## Reset outerpositions to their default value |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
483 opos = getappdata (hsubplots, "__subplotouterposition__"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
484 if (iscell (opos)) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
485 opos = cell2mat (opos); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
486 endif |
26268
6dd232798997
maint: Remove useless ';' from end of for, if, while, etc. statements.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
487 for ii = 1:numel (hsubplots) |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
488 set (hsubplots(ii), "outerposition", opos(ii,:), ... |
28310
1379ebcb00c3
Replace uses of axes property "activepositionproperty" by "positionconstraint" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28177
diff
changeset
|
489 "positionconstraint", "innerposition"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
490 endfor |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
491 |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
492 ## Compare current positions to default and compute the new ones |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
493 curpos = get (hsubplots, "position"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
494 if (iscell (curpos)) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
495 curpos = cell2mat (curpos); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
496 endif |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
497 dx0 = max (curpos(:,1) - pos(:,1)); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
498 dx0(dx0<0) = 0; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
499 dx1 = max ((pos(:,1) + pos(:,3)) - (curpos(:,1) + curpos(:,3))); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
500 dx1(dx1<0) = 0; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
501 dy0 = max (curpos(:,2) - pos(:,2)); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
502 dy0(dy0<0) = 0; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
503 dy1 = max ((pos(:,2) + pos(:,4)) - (curpos(:,2) + curpos(:,4))); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
504 dy1(dy1<0) = 0; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
505 |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
506 pos(:,1) += dx0; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
507 pos(:,2) += dy0; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
508 pos(:,3) -= dx0 + dx1; |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
509 pos(:,4) -= dy0 + dy1; |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
510 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
511 for ii = 1:numel (hsubplots) |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
512 set (hsubplots(ii), "position", pos(ii,:)); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
513 endfor |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
514 |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
515 unwind_protect_cleanup |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
516 updating = false; |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
517 end_unwind_protect |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
518 endif |
17428
9304514b566c
subplot.m: Don't clear axes when switching to existing subplot (most of a fix for bug #39874).
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
519 |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
520 endfunction |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14335
diff
changeset
|
521 |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17312
diff
changeset
|
522 |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
523 %!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
|
524 %! clf; |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
525 %! r = 3; |
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
526 %! c = 3; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
527 %! 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
|
528 %! 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
|
529 %! subplot (r, c, n); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
530 %! xlabel (sprintf ("xlabel #%d", n)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
531 %! ylabel (sprintf ("ylabel #%d", n)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
532 %! title (sprintf ("title #%d", n)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
533 %! text (0.5, 0.5, sprintf ("subplot(%d,%d,%d)", r, c, n), fmt{:}); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
534 %! axis ([0 1 0 1]); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
535 %! endfor |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
536 %! subplot (r, c, 1:3); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
537 %! xlabel (sprintf ("xlabel #%d:%d", 1, 3)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
538 %! ylabel (sprintf ("ylabel #%d:%d", 1, 3)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
539 %! title (sprintf ("title #%d:%d", 1, 3)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
540 %! 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
|
541 %! axis ([0 1 0 1]); |
8744
4142982c66c6
subplot.m: Compatible placement of subplots.
Ben Abbott <bpabbott@mac.com>
parents:
8517
diff
changeset
|
542 |
11305
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
543 %!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
|
544 %! clf; |
11305
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
545 %! x = 0:1; |
c9df571efe95
subplot.m: Add suppport for "align" and "replace" options.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
546 %! for n = 1:4 |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
547 %! subplot (2,2,n, "align"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
548 %! plot (x, x); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
549 %! xlabel (sprintf ("xlabel (2,2,%d)", n)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
550 %! ylabel (sprintf ("ylabel (2,2,%d)", n)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
551 %! title (sprintf ("title (2,2,%d)", n)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
552 %! endfor |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
553 %! subplot (1,2,1, "align"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
554 %! plot (x, x); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
555 %! xlabel ("xlabel (1,2,1)"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
556 %! ylabel ("ylabel (1,2,1)"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
557 %! 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
|
558 |
16975 | 559 %!demo |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
560 %! clf; |
16975 | 561 %! x = 0:10; |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
562 %! ax(1) = subplot (221); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
563 %! set (ax(1), "tag", "1"); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
564 %! plot (x, rand (3, 11)); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
565 %! title ("x & y labels & ticklabels"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
566 %! xlabel xlabel; |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
567 %! ylabel ylabel; |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
568 %! ax(2) = subplot (222); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
569 %! set (ax(2), "tag", "2"); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
570 %! plot (x, rand (3, 11)); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
571 %! title ("no labels"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
572 %! axis ("nolabel","tic"); |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
573 %! ax(3) = subplot (223); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
574 %! set (ax(3), "tag", "3"); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
575 %! plot (x, rand (3, 11)); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
576 %! title ("no labels"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
577 %! axis ("nolabel","tic"); |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
578 %! ax(4) = subplot (224); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
579 %! set (ax(4), "tag", "4"); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
580 %! plot (x, rand (3, 11)); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
581 %! title ("x & y labels & ticklabels"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
582 %! xlabel xlabel; |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
583 %! ylabel ylabel; |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
584 |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
585 %!demo |
24188
1253132e2173
Use "clf;" at beginning of all plot demos.
Rik <rik@octave.org>
parents:
23930
diff
changeset
|
586 %! clf; |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
587 %! x = 0:10; |
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
588 %! subplot (221); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
589 %! plot (x, rand (3, 11)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
590 %! ylim ([0, 1]); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
591 %! text (0.5, 0.5, "{x,y}labels & {x,y}ticklabels", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
592 %! "horizontalalignment", "center", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
593 %! "units", "normalized"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
594 %! xlabel xlabel; |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
595 %! ylabel ylabel; |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
596 %! title title; |
16975 | 597 %! subplot (222); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
598 %! plot (x, rand (3, 11)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
599 %! axis ("labely"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
600 %! ylabel ylabel; |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
601 %! text (0.5, 0.5, "no xlabels, xticklabels", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
602 %! "horizontalalignment", "center", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
603 %! "units", "normalized"); |
16975 | 604 %! subplot (223); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
605 %! plot (x, rand (3, 11)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
606 %! axis ("labelx"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
607 %! text (0.5, 0.5, "no ylabels, yticklabels", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
608 %! "horizontalalignment", "center", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
609 %! "units", "normalized"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
610 %! xlabel xlabel; |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
611 %! title title; |
16975 | 612 %! subplot (224); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
613 %! plot (x, rand (3, 11)); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
614 %! axis ("nolabel", "tic"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
615 %! text (0.5, 0.5, "no {x,y}labels, {x,y}ticklabels", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
616 %! "horizontalalignment", "center", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22173
diff
changeset
|
617 %! "units", "normalized"); |
17012
942d892524b3
Handle alignment of subplots in subplot.m.
Ben Abbott <bpabbott@mac.com>
parents:
16975
diff
changeset
|
618 |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
619 ## Test recognition/deletion of previous axes |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
620 ## Default mode |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
621 %!test |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
622 %! hf = figure ("visible", "off"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
623 %! unwind_protect |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
624 %! for ii = 1:9 |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
625 %! hax(ii) = subplot (3,3,ii); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
626 %! endfor |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
627 %! subplot (3,3,1); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
628 %! assert (gca (), hax(1)); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
629 %! subplot (2,1,1); |
24423
1d52db450db4
Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents:
24188
diff
changeset
|
630 %! assert (ishghandle (hax),[false(1,6), true(1,3)]); |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
631 %! unwind_protect_cleanup |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
632 %! delete (hf); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
633 %! end_unwind_protect |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
634 |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
635 ## Position mode |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
636 %!test |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
637 %! hf = figure ("visible", "off"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
638 %! unwind_protect |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
639 %! h1 = subplot ("position", [0.1 0.1 0.3 0.3]); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
640 %! h2 = subplot ("position", [0.5 0.5 0.3 0.3]); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
641 %! subplot ("position", [0.1 0.1 0.3 0.3]); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
642 %! assert (gca (), h1); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
643 %! subplot ("position", [0.5 0.5 0.3 0.3]); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
644 %! assert (gca (), h2); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
645 %! subplot ("position", [0.5 0.5 0.3 0.2]); |
24423
1d52db450db4
Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents:
24188
diff
changeset
|
646 %! assert (! ishghandle (h2)); |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
647 %! unwind_protect_cleanup |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
648 %! delete (hf); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
649 %! end_unwind_protect |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
650 |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
651 ## Align mode |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
652 %!test |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
653 %! hf = figure ("visible", "off"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
654 %! unwind_protect |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
655 %! h1 = subplot (3,5,1, "align"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
656 %! h2 = subplot (3,5,2, "align"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
657 %! subplot (3,5,1, "align"); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
658 %! assert (gca (), h1); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
659 %! subplot (3,2,1, "align"); |
24423
1d52db450db4
Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents:
24188
diff
changeset
|
660 %! assert (! ishghandle (h1)); |
1d52db450db4
Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents:
24188
diff
changeset
|
661 %! assert (! ishghandle (h2)); |
19687
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
662 %! unwind_protect_cleanup |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
663 %! delete (hf); |
8064b5cdbc11
subplot.m: fix deletion of previous subplots (bug #41128)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19593
diff
changeset
|
664 %! end_unwind_protect |