Mercurial > hg > octave-nkf
annotate scripts/plot/plotmatrix.m @ 17122:eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Emphasize clarity, use common "voice", and increase density of seealso links.
* doc/interpreter/plot.txi: Add @findex entries that were in xlim.m
* scripts/miscellaneous/getappdata.m scripts/miscellaneous/setappdata.m,
scripts/plot/allchild.m, scripts/plot/ancestor.m, scripts/plot/area.m,
scripts/plot/axes.m, scripts/plot/axis.m, scripts/plot/bar.m,
scripts/plot/barh.m, scripts/plot/box.m, scripts/plot/caxis.m,
scripts/plot/cla.m, scripts/plot/clabel.m, scripts/plot/clf.m,
scripts/plot/close.m, scripts/plot/closereq.m, scripts/plot/colorbar.m,
scripts/plot/comet.m, scripts/plot/comet3.m, scripts/plot/compass.m,
scripts/plot/contour.m, scripts/plot/contour3.m, scripts/plot/contourc.m,
scripts/plot/contourf.m, scripts/plot/copyobj.m, scripts/plot/cylinder.m,
scripts/plot/daspect.m, scripts/plot/diffuse.m, scripts/plot/ellipsoid.m,
scripts/plot/errorbar.m, scripts/plot/ezcontour.m, scripts/plot/ezcontourf.m,
scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m, scripts/plot/ezplot.m,
scripts/plot/ezplot3.m, scripts/plot/ezpolar.m, scripts/plot/ezsurf.m,
scripts/plot/ezsurfc.m, scripts/plot/feather.m, scripts/plot/figure.m,
scripts/plot/fill.m, scripts/plot/findall.m, scripts/plot/findobj.m,
scripts/plot/fplot.m, scripts/plot/gca.m, scripts/plot/gcbf.m,
scripts/plot/gcbo.m, scripts/plot/gcf.m, scripts/plot/gco.m,
scripts/plot/ginput.m, scripts/plot/graphics_toolkit.m, scripts/plot/grid.m,
scripts/plot/gtext.m, scripts/plot/guidata.m, scripts/plot/guihandles.m,
scripts/plot/hdl2struct.m, scripts/plot/hggroup.m, scripts/plot/hidden.m,
scripts/plot/hist.m, scripts/plot/hold.m, scripts/plot/ishghandle.m,
scripts/plot/ishold.m, scripts/plot/isocolors.m, scripts/plot/isprop.m,
scripts/plot/legend.m, scripts/plot/line.m, scripts/plot/linkprop.m,
scripts/plot/loglog.m, scripts/plot/loglogerr.m, scripts/plot/mesh.m,
scripts/plot/meshc.m, scripts/plot/meshgrid.m, scripts/plot/meshz.m,
scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m,
scripts/plot/patch.m, scripts/plot/pcolor.m, scripts/plot/peaks.m,
scripts/plot/pie.m, scripts/plot/pie3.m, scripts/plot/plot.m,
scripts/plot/plot3.m, scripts/plot/plotmatrix.m, scripts/plot/plotyy.m,
scripts/plot/polar.m, scripts/plot/print.m, scripts/plot/quiver.m,
scripts/plot/quiver3.m, scripts/plot/rectangle.m, scripts/plot/refresh.m,
scripts/plot/refreshdata.m, scripts/plot/ribbon.m, scripts/plot/rose.m,
scripts/plot/saveas.m, scripts/plot/scatter.m, scripts/plot/scatter3.m,
scripts/plot/semilogx.m, scripts/plot/semilogxerr.m, scripts/plot/semilogy.m,
scripts/plot/semilogyerr.m, scripts/plot/shading.m, scripts/plot/shg.m,
scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/specular.m,
scripts/plot/sphere.m, scripts/plot/stairs.m, scripts/plot/stem.m,
scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m,
scripts/plot/surf.m, scripts/plot/surface.m, scripts/plot/surfc.m,
scripts/plot/surfl.m, scripts/plot/tetramesh.m, scripts/plot/text.m,
scripts/plot/title.m, scripts/plot/trimesh.m, scripts/plot/triplot.m,
scripts/plot/trisurf.m, scripts/plot/view.m, scripts/plot/waitbar.m,
scripts/plot/waitforbuttonpress.m, scripts/plot/waterfall.m,
scripts/plot/whitebg.m, scripts/plot/xlabel.m, scripts/plot/xlim.m,
scripts/plot/ylabel.m, scripts/plot/ylim.m, scripts/plot/zlabel.m,
scripts/plot/zlim.m: Rewrite docstrings for most plot functions.
Emphasize clarity, use common "voice", and increase density of seealso links.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 31 Jul 2013 13:53:30 -0700 |
parents | 5dae8af4773d |
children | b5d6314314fc |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14092
diff
changeset
|
1 ## Copyright (C) 2008-2012 David Bateman |
8127 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
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 | 21 ## @deftypefnx {Function File} {} plotmatrix (@var{x}) |
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 | 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 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17056
diff
changeset
|
27 ## Given the arguments @var{x} and @var{y}, that have a matching number of |
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 | 29 ## |
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 | 32 ## @end example |
33 ## | |
16814
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
16086
diff
changeset
|
34 ## Given a single argument @var{x} this is equivalent to |
8127 | 35 ## |
36 ## @example | |
37 ## plotmatrix (@var{x}, @var{x}) | |
38 ## @end example | |
39 ## | |
40 ## @noindent | |
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 | 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 | 49 ## |
50 ## The optional return value @var{h} provides handles to the individual | |
51 ## graphics objects in the scatter plots, whereas @var{ax} returns the | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8190
diff
changeset
|
52 ## handles to the scatter plot axis objects. @var{bigax} is a hidden |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
53 ## axis object that surrounds the other axes, such that the commands |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
54 ## @code{xlabel}, @code{title}, etc., will be associated with this hidden |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17056
diff
changeset
|
55 ## axis. Finally, @var{p} returns the graphics objects associated with |
8127 | 56 ## the histogram and @var{pax} the corresponding axes objects. |
57 ## | |
17056
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
58 ## Example: |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
59 ## |
8127 | 60 ## @example |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
61 ## plotmatrix (randn (100, 3), "g+") |
8127 | 62 ## @end example |
63 ## | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17056
diff
changeset
|
64 ## @seealso{scatter, plot} |
8127 | 65 ## @end deftypefn |
66 | |
67 function [h, ax, bigax, p, pax] = plotmatrix (varargin) | |
68 | |
69 [bigax2, varargin, nargin] = __plt_get_axis_arg__ ("plotmatrix", varargin{:}); | |
70 | |
71 if (nargin > 3 || nargin < 1) | |
72 print_usage (); | |
73 endif | |
17056
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
74 |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
75 oldfig = ifelse (isempty (bigax2), [], get (0, "currentfigure")); |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
76 unwind_protect |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
77 bigax2 = newplot (bigax2); |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
78 |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
79 [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
|
80 |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
81 if (nargout > 0) |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
82 h = h2; |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
83 ax = ax2; |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
84 bigax = bigax2; |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
85 p = p2; |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
86 pax = pax2; |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
87 endif |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
88 axes (bigax2); |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
89 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
|
90 "handlevisibility", "off", "xliminclude", "off", |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
91 "yliminclude", "off", "zliminclude", "off", |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
92 "deletefcn", {@plotmatrixdelete, [ax2; pax2]}); |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
93 set (bigax2, "visible", "off"); |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
94 |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
95 unwind_protect_cleanup |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
96 if (! isempty (oldfig)) |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
97 set (0, "currentfigure", oldfig); |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
98 endif |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
99 end_unwind_protect |
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
100 |
8127 | 101 endfunction |
102 | |
17056
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
103 |
8127 | 104 %!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
|
105 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
106 %! plotmatrix (randn (100, 3), 'g+'); |
8127 | 107 |
17056
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
108 |
8127 | 109 function plotmatrixdelete (h, d, ax) |
110 for i = 1 : numel (ax) | |
111 hc = ax(i); | |
11149
fe3c3dfc07eb
style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents:
10793
diff
changeset
|
112 if (ishandle (hc) && strcmp (get (hc, "type"), "axes") |
fe3c3dfc07eb
style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents:
10793
diff
changeset
|
113 && strcmpi (get (hc, "beingdeleted"), "off")) |
8127 | 114 parent = get (hc, "parent"); |
115 ## 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
|
116 if (ishandle (parent) && strcmpi (get (parent, "beingdeleted"), "off")) |
10549 | 117 delete (hc); |
8127 | 118 endif |
119 endif | |
120 endfor | |
121 endfunction | |
122 | |
17056
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
123 function [h, ax, p, pax] = __plotmatrix__ (bigax, varargin) |
8127 | 124 have_line_spec = false; |
125 have_hist = false; | |
126 parent = get (bigax, "parent"); | |
127 for i = 1 : nargin - 1 | |
128 arg = varargin{i}; | |
129 if (ischar (arg) || iscell (arg)) | |
130 [linespec, valid] = __pltopt__ ("plotmatrix", varargin{i}, false); | |
131 if (valid) | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
132 have_line_spec = true; |
10549 | 133 linespec = varargin(i); |
134 varargin(i) = []; | |
135 nargin = nargin - 1; | |
136 break; | |
8127 | 137 else |
17056
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
138 print_usage ("plotmatrix"); |
8127 | 139 endif |
140 endif | |
141 endfor | |
142 | |
143 if (nargin == 2) | |
144 X = varargin{1}; | |
145 Y = X; | |
146 have_hist = true; | |
147 elseif (nargin == 3) | |
148 X = varargin{1}; | |
149 Y = varargin{2}; | |
150 else | |
17056
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
151 print_usage ("plotmatrix"); |
8127 | 152 endif |
153 | |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14335
diff
changeset
|
154 if (rows (X) != rows (Y)) |
8127 | 155 error ("plotmatrix: dimension mismatch in the arguments"); |
156 endif | |
157 | |
158 [dummy, m] = size (X); | |
159 [dummy, n] = size (Y); | |
160 | |
161 h = []; | |
162 ax = []; | |
163 p = []; | |
164 pax = []; | |
165 | |
166 xsize = 0.9 / m; | |
167 ysize = 0.9 / n; | |
168 xoff = 0.05; | |
169 yoff = 0.05; | |
170 border = [0.130, 0.110, 0.225, 0.185] .* [xsize, ysize, xsize, ysize]; | |
171 border(3:4) = - border(3:4) - border(1:2); | |
172 | |
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
|
173 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
|
174 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
|
175 pos = [xsize * (i - 1) + xoff, ysize * (n - j) + yoff, xsize, ysize]; |
8127 | 176 tmp = axes ("outerposition", pos, "position", pos + border, |
10549 | 177 "parent", parent); |
8127 | 178 if (i == j && have_hist) |
10549 | 179 pax = [pax ; tmp]; |
180 [nn, xx] = hist (X(:, i)); | |
181 tmp = bar (xx, nn, 1.0); | |
182 p = [p; tmp]; | |
8127 | 183 else |
10549 | 184 ax = [ax ; tmp]; |
185 if (have_line_spec) | |
186 tmp = plot (X (:, i), Y (:, j), linespec); | |
187 else | |
188 tmp = plot (X (:, i), Y (:, j), "."); | |
189 endif | |
190 h = [h ; tmp]; | |
8127 | 191 endif |
192 endfor | |
193 endfor | |
194 endfunction | |
17056
5dae8af4773d
plotmatrix.m: Overhaul function to use new__plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
195 |