annotate scripts/plot/draw/plotmatrix.m @ 29359:7854d5752dd2

maint: merge stable to default.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 10:10:40 -0500
parents 28de41192f3c 0a5b15007766
children 6c53b9bf6b19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 ##
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 ## Copyright (C) 2008-2021 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/>.
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
7 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
8 ## This file is part of Octave.
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
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
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
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.
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
14 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
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.
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
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 ########################################################################
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
25
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20512
diff changeset
27 ## @deftypefn {} {} plotmatrix (@var{x}, @var{y})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20512
diff changeset
28 ## @deftypefnx {} {} plotmatrix (@var{x})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20512
diff changeset
29 ## @deftypefnx {} {} plotmatrix (@dots{}, @var{style})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20512
diff changeset
30 ## @deftypefnx {} {} plotmatrix (@var{hax}, @dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20512
diff changeset
31 ## @deftypefnx {} {[@var{h}, @var{ax}, @var{bigax}, @var{p}, @var{pax}] =} plotmatrix (@dots{})
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17056
diff changeset
32 ## Scatter plot of the columns of one matrix against another.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17056
diff changeset
33 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
34 ## Given the arguments @var{x} and @var{y} that have a matching number of
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17056
diff changeset
35 ## rows, @code{plotmatrix} plots a set of axes corresponding to
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
36 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
37 ## @example
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16086
diff changeset
38 ## plot (@var{x}(:, i), @var{y}(:, j))
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
39 ## @end example
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
40 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
41 ## When called with a single argument @var{x} this is equivalent to
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
42 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
43 ## @example
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
44 ## plotmatrix (@var{x}, @var{x})
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
45 ## @end example
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
46 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
47 ## @noindent
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
48 ## except that the diagonal of the set of axes will be replaced with the
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16086
diff changeset
49 ## histogram @code{hist (@var{x}(:, i))}.
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
50 ##
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
51 ## The marker to use can be changed with the @var{style} argument, that is a
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
52 ## string defining a marker in the same manner as the @code{plot} command.
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
53 ##
24431
0c6cedafc71e doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents: 23219
diff changeset
54 ## If the first argument @var{hax} is an axes handle, then plot into this axes,
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17056
diff changeset
55 ## rather than the current axes returned by @code{gca}.
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
56 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
57 ## The optional return value @var{h} provides handles to the individual
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
58 ## graphics objects in the scatter plots, whereas @var{ax} returns the
24431
0c6cedafc71e doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents: 23219
diff changeset
59 ## handles to the scatter plot axes objects.
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
60 ##
24431
0c6cedafc71e doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents: 23219
diff changeset
61 ## @var{bigax} is a hidden axes object that surrounds the other axes, such
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
62 ## that the commands @code{xlabel}, @code{title}, etc., will be associated
24431
0c6cedafc71e doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents: 23219
diff changeset
63 ## with this hidden axes.
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
64 ##
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
65 ## Finally, @var{p} returns the graphics objects associated with the histogram
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
66 ## and @var{pax} the corresponding axes objects.
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
67 ##
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
68 ## Example:
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
69 ##
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
70 ## @example
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
71 ## plotmatrix (randn (100, 3), "g+")
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
72 ## @end example
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
73 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17056
diff changeset
74 ## @seealso{scatter, plot}
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
75 ## @end deftypefn
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
76
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
77 function [h, ax, bigax, p, pax] = plotmatrix (varargin)
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
78
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
79 [bigax2, varargin, nargin] = __plt_get_axis_arg__ ("plotmatrix", varargin{:});
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
80
28789
28de41192f3c Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents: 28595
diff changeset
81 if (nargin < 1 || nargin > 3)
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
82 print_usage ();
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
83 endif
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
84
17302
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
85 oldfig = [];
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
86 if (! isempty (bigax2))
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
87 oldfig = get (0, "currentfigure");
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
88 endif
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
89 unwind_protect
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
90 bigax2 = newplot (bigax2);
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
91
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
92 [h2, ax2, p2, pax2] = __plotmatrix__ (bigax2, varargin{:});
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
93
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
94 axes (bigax2);
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
95 ctext = text (0, 0, "", "visible", "off",
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
96 "handlevisibility", "off", "xliminclude", "off",
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
97 "yliminclude", "off", "zliminclude", "off",
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
98 "deletefcn", {@plotmatrixdelete, [ax2; pax2]});
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
99 set (bigax2, "visible", "off");
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
100
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
101 unwind_protect_cleanup
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
102 if (! isempty (oldfig))
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
103 set (0, "currentfigure", oldfig);
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
104 endif
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
105 end_unwind_protect
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
106
17302
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
107 if (nargout > 0)
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
108 h = h2;
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
109 ax = ax2;
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
110 bigax = bigax2;
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
111 p = p2;
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
112 pax = pax2;
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
113 endif
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
114
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
115 endfunction
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
116
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
117
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
118 %!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
119 %! clf;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21758
diff changeset
120 %! plotmatrix (randn (100, 3), "g+");
24388
206ef5cb8b16 Add titles to most plot demos.
Rik <rik@octave.org>
parents: 23220
diff changeset
121 %! title ("plotmatrix() demo #1");
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
122
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
123
28595
4deb794d85e2 Resolve further number of argument mismatch in graphics callbacks (bug #58821)
Rik <rik@octave.org>
parents: 27923
diff changeset
124 function plotmatrixdelete (h, ~, ax)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
125
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
126 for i = 1 : numel (ax)
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
127 hc = ax(i);
17125
b5d6314314fc Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents: 17122
diff changeset
128 if (isaxes (hc) && strcmpi (get (hc, "beingdeleted"), "off"))
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
129 parent = get (hc, "parent");
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
130 ## If the parent is invalid or being deleted, then do nothing
24423
1d52db450db4 Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents: 24388
diff changeset
131 if (ishghandle (parent) && strcmpi (get (parent, "beingdeleted"), "off"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
132 delete (hc);
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
133 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
134 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
135 endfor
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
136
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
137 endfunction
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
138
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
139 function [h, ax, p, pax] = __plotmatrix__ (bigax, varargin)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
140
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
141 have_line_spec = false;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
142 have_hist = false;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
143 parent = get (bigax, "parent");
20512
8164c580922b plotmatrix.m: Fix regression in %!demo introduced by in-place operators.
Rik <rik@octave.org>
parents: 20231
diff changeset
144 narg = nargin ();
8164c580922b plotmatrix.m: Fix regression in %!demo introduced by in-place operators.
Rik <rik@octave.org>
parents: 20231
diff changeset
145 for i = 1 : narg - 1
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
146 arg = varargin{i};
17462
177147bf7b55 Overhaul use of __pltopt__.m to correctly check for cellstr, not just cell.
Rik <rik@octave.org>
parents: 17302
diff changeset
147 if (ischar (arg) || iscellstr (arg))
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
148 [linespec, valid] = __pltopt__ ("plotmatrix", varargin{i}, false);
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
149 if (valid)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
150 have_line_spec = true;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
151 linespec = varargin(i);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
152 varargin(i) = [];
20512
8164c580922b plotmatrix.m: Fix regression in %!demo introduced by in-place operators.
Rik <rik@octave.org>
parents: 20231
diff changeset
153 narg -= 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
154 break;
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
155 else
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
156 print_usage ("plotmatrix");
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
157 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
158 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
159 endfor
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
160
20512
8164c580922b plotmatrix.m: Fix regression in %!demo introduced by in-place operators.
Rik <rik@octave.org>
parents: 20231
diff changeset
161 if (narg == 2)
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
162 X = varargin{1};
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
163 Y = X;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
164 have_hist = true;
20512
8164c580922b plotmatrix.m: Fix regression in %!demo introduced by in-place operators.
Rik <rik@octave.org>
parents: 20231
diff changeset
165 elseif (narg == 3)
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
166 X = varargin{1};
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
167 Y = varargin{2};
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
168 else
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
169 print_usage ("plotmatrix");
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
170 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
171
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14335
diff changeset
172 if (rows (X) != rows (Y))
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
173 error ("plotmatrix: dimension mismatch in the arguments");
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
174 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
175
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
176 [dummy, m] = size (X);
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
177 [dummy, n] = size (Y);
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
178
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
179 h = [];
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
180 ax = [];
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
181 p = [];
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
182 pax = [];
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
183
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
184 xsize = 0.9 / m;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
185 ysize = 0.9 / n;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
186 xoff = 0.05;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
187 yoff = 0.05;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
188 border = [0.130, 0.110, 0.225, 0.185] .* [xsize, ysize, xsize, ysize];
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
189 border(3:4) = - border(3:4) - border(1:2);
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
190
16086
f89760972bf4 plotmatrix.m: Fix bug when number of columns in 2 inputs differs (bug #38368)
Julien Bect <julien.bect@supelec.fr>
parents: 14868
diff changeset
191 for i = 1 : m
f89760972bf4 plotmatrix.m: Fix bug when number of columns in 2 inputs differs (bug #38368)
Julien Bect <julien.bect@supelec.fr>
parents: 14868
diff changeset
192 for j = 1 : n
f89760972bf4 plotmatrix.m: Fix bug when number of columns in 2 inputs differs (bug #38368)
Julien Bect <julien.bect@supelec.fr>
parents: 14868
diff changeset
193 pos = [xsize * (i - 1) + xoff, ysize * (n - j) + yoff, xsize, ysize];
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
194 tmp = axes ("outerposition", pos, "position", pos + border,
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
195 "parent", parent);
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
196 if (i == j && have_hist)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
197 pax = [pax ; tmp];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
198 [nn, xx] = hist (X(:, i));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
199 tmp = bar (xx, nn, 1.0);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
200 p = [p; tmp];
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
201 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
202 ax = [ax ; tmp];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
203 if (have_line_spec)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
204 tmp = plot (X (:, i), Y (:, j), linespec);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
205 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
206 tmp = plot (X (:, i), Y (:, j), ".");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
207 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
208 h = [h ; tmp];
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
209 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
210 endfor
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
211 endfor
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
212
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
213 endfunction