Mercurial > hg > octave-nkf
annotate scripts/plot/private/__line__.m @ 16491:b10a23fe80bb
doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility.
* scripts/audio/wavread.m, scripts/miscellaneous/getappdata.m,
scripts/miscellaneous/license.m, scripts/miscellaneous/ver.m,
scripts/plot/daspect.m, scripts/plot/graphics_toolkit.m,
scripts/plot/pbaspect.m, scripts/polynomial/splinefit.m, scripts/set/union.m,
scripts/signal/freqz.m: Improve docstring wording.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 10 Apr 2013 22:43:30 -0700 |
parents | 8150ccfffa22 |
children | abf384f5d243 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13268
diff
changeset
|
1 ## Copyright (C) 2005-2012 John W. Eaton |
6405 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6405 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6405 | 18 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8078
diff
changeset
|
19 ## -*- texinfo -*- |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8078
diff
changeset
|
20 ## @deftypefn {Function File} {@var{h} =} __line__ (@var{p}, @dots{}) |
6895 | 21 ## Undocumented internal function. |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8078
diff
changeset
|
22 ## @end deftypefn |
6895 | 23 |
24 ## __line__ (p, x, y, z) | |
25 ## Create line object from x, y, and z with parent p. | |
6405 | 26 ## Return handle to line object. |
27 | |
28 ## Author: jwe | |
29 | |
30 function h = __line__ (p, varargin) | |
31 | |
32 if (nargin < 1) | |
33 print_usage (); | |
34 endif | |
35 | |
36 nvargs = numel (varargin); | |
37 | |
14434
3d4f7631baff
Allow plot3 to accept booleans (bug #33607)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
38 if (nvargs > 1 && ! ischar (varargin{1}) && ! ischar (varargin{2})) |
3d4f7631baff
Allow plot3 to accept booleans (bug #33607)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
39 if (nvargs > 2 && ! ischar (varargin{3})) |
6405 | 40 num_data_args = 3; |
41 else | |
42 num_data_args = 2; | |
43 endif | |
44 else | |
45 num_data_args = 0; | |
46 endif | |
47 | |
13248
248d05c413dc
Validate inputs to line() to prevent corrupting graphic toolkit (Bug #32345)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
48 if (num_data_args > 0 && ! size_equal (varargin{1:num_data_args})) |
14535
8150ccfffa22
Apply broadcasting to inputs of line().
Ben Abbott <bpabbott@mac.com>
parents:
14434
diff
changeset
|
49 n = 1:num_data_args; |
8150ccfffa22
Apply broadcasting to inputs of line().
Ben Abbott <bpabbott@mac.com>
parents:
14434
diff
changeset
|
50 m = cellfun (@numel, varargin(1:num_data_args)); |
8150ccfffa22
Apply broadcasting to inputs of line().
Ben Abbott <bpabbott@mac.com>
parents:
14434
diff
changeset
|
51 [~, m] = max (m); |
8150ccfffa22
Apply broadcasting to inputs of line().
Ben Abbott <bpabbott@mac.com>
parents:
14434
diff
changeset
|
52 b = ones (size (varargin{m(1)})); |
8150ccfffa22
Apply broadcasting to inputs of line().
Ben Abbott <bpabbott@mac.com>
parents:
14434
diff
changeset
|
53 try |
8150ccfffa22
Apply broadcasting to inputs of line().
Ben Abbott <bpabbott@mac.com>
parents:
14434
diff
changeset
|
54 varargin(n) = cellfun (@(x) bsxfun (@times, b, x), varargin(n), "uniformoutput", false); |
8150ccfffa22
Apply broadcasting to inputs of line().
Ben Abbott <bpabbott@mac.com>
parents:
14434
diff
changeset
|
55 catch |
8150ccfffa22
Apply broadcasting to inputs of line().
Ben Abbott <bpabbott@mac.com>
parents:
14434
diff
changeset
|
56 error ("line: number of X, Y, and Z points must be equal"); |
8150ccfffa22
Apply broadcasting to inputs of line().
Ben Abbott <bpabbott@mac.com>
parents:
14434
diff
changeset
|
57 end_try_catch |
13248
248d05c413dc
Validate inputs to line() to prevent corrupting graphic toolkit (Bug #32345)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
58 endif |
248d05c413dc
Validate inputs to line() to prevent corrupting graphic toolkit (Bug #32345)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
59 |
8078
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
7277
diff
changeset
|
60 if (rem (nvargs - num_data_args, 2) != 0) |
13248
248d05c413dc
Validate inputs to line() to prevent corrupting graphic toolkit (Bug #32345)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
61 error ("line: invalid number of PROPERTY / VALUE pairs"); |
6405 | 62 endif |
63 | |
7277 | 64 other_args = {}; |
6405 | 65 if (nvargs > num_data_args) |
7277 | 66 other_args = varargin(num_data_args+1:end); |
6405 | 67 endif |
68 | |
13235
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
69 nlines = 0; |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
70 nvecpts = 0; |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
71 ismat = false (1, 3); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
72 for i = 1:num_data_args |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
73 tmp = varargin{i}(:,:); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
74 if (isvector (tmp)) |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
75 nlines = max (1, nlines); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
76 if (! isscalar (tmp)) |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
77 if (nvecpts == 0) |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
78 nvecpts = numel (tmp); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
79 elseif (nvecpts != numel (tmp)) |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
80 error ("line: data size mismatch"); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
81 endif |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
82 endif |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
83 else |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
84 ismat(i) = true; |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
85 nlines = max (columns (tmp), nlines); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
86 endif |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
87 varargin{i} = tmp; |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
88 endfor |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
89 |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
90 if (num_data_args == 0) |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
91 varargin = {[0, 1], [0, 1]}; |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
92 num_data_args = 2; |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
93 nlines = 1; |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
94 endif |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
95 |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
96 handles = zeros (nlines, 1); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
97 |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
98 data = cell (1, 3); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
99 |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
100 if (num_data_args > 1) |
14434
3d4f7631baff
Allow plot3 to accept booleans (bug #33607)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
101 data(1:num_data_args) = varargin(1:num_data_args); |
3d4f7631baff
Allow plot3 to accept booleans (bug #33607)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
102 for i = 1:num_data_args |
3d4f7631baff
Allow plot3 to accept booleans (bug #33607)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
103 if (islogical (data{i})) |
3d4f7631baff
Allow plot3 to accept booleans (bug #33607)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
104 data(i) = double (data{i}); |
3d4f7631baff
Allow plot3 to accept booleans (bug #33607)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
105 elseif (iscomplex (data{i})) |
3d4f7631baff
Allow plot3 to accept booleans (bug #33607)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
106 data(i) = real (data{i}); |
3d4f7631baff
Allow plot3 to accept booleans (bug #33607)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
107 endif |
3d4f7631baff
Allow plot3 to accept booleans (bug #33607)
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
108 endfor |
13235
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
109 endif |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
110 |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
111 data_args = reshape ({"xdata", "ydata", "zdata"; data{:}}, [1, 6]); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
112 mask = reshape ([false(1,3); ismat], [1, 6]); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
113 |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
114 for i = 1:nlines |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
115 tmp = data(ismat); |
13238
7467e90271f4
fix thinko in previous change to __line__.m
John W. Eaton <jwe@octave.org>
parents:
13235
diff
changeset
|
116 if (! size_equal (tmp) |
7467e90271f4
fix thinko in previous change to __line__.m
John W. Eaton <jwe@octave.org>
parents:
13235
diff
changeset
|
117 || (nvecpts != 0 && any (nvecpts != cellfun ("size", tmp, 1)))) |
13235
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
118 error ("line: data size_mismatch"); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
119 endif |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
120 |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
121 data_args(mask) = cellfun (@(x) x(:,i), data(ismat), |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
122 "uniformoutput", false); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
123 |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
124 handles(i) = __go_line__ (p, data_args{:}, other_args{:}); |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
125 |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
126 endfor |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
127 |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
128 if (nargout > 0) |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
129 h = handles; |
7b3afe09680b
allow line function to accept matrix arguments
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
130 endif |
7277 | 131 |
6405 | 132 endfunction |