annotate scripts/plot/draw/plotmatrix.m @ 20547:8164c580922b

plotmatrix.m: Fix regression in %!demo introduced by in-place operators. * plotmatrix.m: Rename nargin variable to narg variable to avoid shadowing nargin() function.
author Rik <rik@octave.org>
date Fri, 25 Sep 2015 13:05:01 -0700
parents 83792dd9bcc1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
1 ## Copyright (C) 2008-2015 David Bateman
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
2 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
3 ## This file is part of Octave.
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
4 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
8 ## your option) any later version.
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
9 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
10 ## 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
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
13 ## General Public License for more details.
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 ## 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
16 ## along with Octave; see the file COPYING. If not, see
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
18
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
20 ## @deftypefn {Function File} {} plotmatrix (@var{x}, @var{y})
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
21 ## @deftypefnx {Function File} {} plotmatrix (@var{x})
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
22 ## @deftypefnx {Function File} {} plotmatrix (@dots{}, @var{style})
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
23 ## @deftypefnx {Function File} {} plotmatrix (@var{hax}, @dots{})
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
24 ## @deftypefnx {Function File} {[@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
25 ## 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
26 ##
20208
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
27 ## 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
28 ## rows, @code{plotmatrix} plots a set of axes corresponding to
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
29 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
30 ## @example
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16086
diff changeset
31 ## plot (@var{x}(:, i), @var{y}(:, j))
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
32 ## @end example
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
33 ##
20208
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
34 ## 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
35 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
36 ## @example
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
37 ## plotmatrix (@var{x}, @var{x})
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
38 ## @end example
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
39 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
40 ## @noindent
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
41 ## 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
42 ## histogram @code{hist (@var{x}(:, i))}.
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
43 ##
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
44 ## 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
45 ## 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
46 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17056
diff changeset
47 ## If the first argument @var{hax} is an axes handle, then plot into this axis,
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17056
diff changeset
48 ## rather than the current axes returned by @code{gca}.
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
49 ##
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
50 ## The optional return value @var{h} provides handles to the individual
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
51 ## graphics objects in the scatter plots, whereas @var{ax} returns the
20208
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
52 ## handles to the scatter plot axis objects.
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
53 ##
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
54 ## @var{bigax} is a hidden axis object that surrounds the other axes, such
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
55 ## that the commands @code{xlabel}, @code{title}, etc., will be associated
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
56 ## with this hidden axis.
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
57 ##
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19731
diff changeset
58 ## 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: 19731
diff changeset
59 ## and @var{pax} the corresponding axes objects.
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
60 ##
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
61 ## Example:
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
62 ##
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
63 ## @example
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
64 ## plotmatrix (randn (100, 3), "g+")
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
65 ## @end example
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
66 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17056
diff changeset
67 ## @seealso{scatter, plot}
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
68 ## @end deftypefn
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
69
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
70 function [h, ax, bigax, p, pax] = plotmatrix (varargin)
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
71
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
72 [bigax2, varargin, nargin] = __plt_get_axis_arg__ ("plotmatrix", varargin{:});
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
73
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
74 if (nargin > 3 || nargin < 1)
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
75 print_usage ();
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
76 endif
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
77
17302
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
78 oldfig = [];
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
79 if (! isempty (bigax2))
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
80 oldfig = get (0, "currentfigure");
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
81 endif
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
82 unwind_protect
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
83 bigax2 = newplot (bigax2);
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
84
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
85 [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
86
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
87 axes (bigax2);
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
88 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
89 "handlevisibility", "off", "xliminclude", "off",
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
90 "yliminclude", "off", "zliminclude", "off",
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
91 "deletefcn", {@plotmatrixdelete, [ax2; pax2]});
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
92 set (bigax2, "visible", "off");
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 unwind_protect_cleanup
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
95 if (! isempty (oldfig))
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
96 set (0, "currentfigure", oldfig);
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
97 endif
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
98 end_unwind_protect
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
99
17302
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
100 if (nargout > 0)
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
101 h = h2;
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
102 ax = ax2;
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
103 bigax = bigax2;
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
104 p = p2;
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
105 pax = pax2;
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
106 endif
6ba5b1dadd61 plotmatrix.m: Replace ifelse() construction with if/endif.
Rik <rik@octave.org>
parents: 17125
diff changeset
107
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
108 endfunction
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
109
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
110
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
111 %!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
112 %! clf;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
113 %! plotmatrix (randn (100, 3), 'g+');
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
114
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
115
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
116 function plotmatrixdelete (h, d, ax)
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
117 for i = 1 : numel (ax)
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
118 hc = ax(i);
17125
b5d6314314fc Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents: 17122
diff changeset
119 if (isaxes (hc) && strcmpi (get (hc, "beingdeleted"), "off"))
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
120 parent = get (hc, "parent");
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
121 ## If the parent is invalid or being deleted, then do nothing
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 8127
diff changeset
122 if (ishandle (parent) && strcmpi (get (parent, "beingdeleted"), "off"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
123 delete (hc);
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
124 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
125 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
126 endfor
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
127 endfunction
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
128
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
129 function [h, ax, p, pax] = __plotmatrix__ (bigax, varargin)
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
130 have_line_spec = false;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
131 have_hist = false;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
132 parent = get (bigax, "parent");
20547
8164c580922b plotmatrix.m: Fix regression in %!demo introduced by in-place operators.
Rik <rik@octave.org>
parents: 20266
diff changeset
133 narg = nargin ();
8164c580922b plotmatrix.m: Fix regression in %!demo introduced by in-place operators.
Rik <rik@octave.org>
parents: 20266
diff changeset
134 for i = 1 : narg - 1
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
135 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
136 if (ischar (arg) || iscellstr (arg))
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
137 [linespec, valid] = __pltopt__ ("plotmatrix", varargin{i}, false);
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
138 if (valid)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
139 have_line_spec = true;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
140 linespec = varargin(i);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
141 varargin(i) = [];
20547
8164c580922b plotmatrix.m: Fix regression in %!demo introduced by in-place operators.
Rik <rik@octave.org>
parents: 20266
diff changeset
142 narg -= 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
143 break;
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
144 else
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
145 print_usage ("plotmatrix");
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
146 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
147 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
148 endfor
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
149
20547
8164c580922b plotmatrix.m: Fix regression in %!demo introduced by in-place operators.
Rik <rik@octave.org>
parents: 20266
diff changeset
150 if (narg == 2)
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
151 X = varargin{1};
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
152 Y = X;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
153 have_hist = true;
20547
8164c580922b plotmatrix.m: Fix regression in %!demo introduced by in-place operators.
Rik <rik@octave.org>
parents: 20266
diff changeset
154 elseif (narg == 3)
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
155 X = varargin{1};
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
156 Y = varargin{2};
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
157 else
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
158 print_usage ("plotmatrix");
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
159 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
160
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14335
diff changeset
161 if (rows (X) != rows (Y))
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
162 error ("plotmatrix: dimension mismatch in the arguments");
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
163 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
164
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
165 [dummy, m] = size (X);
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
166 [dummy, n] = size (Y);
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
167
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
168 h = [];
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
169 ax = [];
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
170 p = [];
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
171 pax = [];
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
172
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
173 xsize = 0.9 / m;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
174 ysize = 0.9 / n;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
175 xoff = 0.05;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
176 yoff = 0.05;
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
177 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
178 border(3:4) = - border(3:4) - border(1:2);
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
179
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
180 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
181 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
182 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
183 tmp = axes ("outerposition", pos, "position", pos + border,
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
184 "parent", parent);
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
185 if (i == j && have_hist)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
186 pax = [pax ; tmp];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
187 [nn, xx] = hist (X(:, i));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
188 tmp = bar (xx, nn, 1.0);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
189 p = [p; tmp];
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
190 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
191 ax = [ax ; tmp];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
192 if (have_line_spec)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
193 tmp = plot (X (:, i), Y (:, j), linespec);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
194 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
195 tmp = plot (X (:, i), Y (:, j), ".");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
196 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
197 h = [h ; tmp];
8127
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
198 endif
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
199 endfor
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
200 endfor
86568be36992 Add the plotmatrix function
David Bateman <dbateman@free.fr>
parents:
diff changeset
201 endfunction
17056
5dae8af4773d plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
202