Mercurial > octave
annotate scripts/plot/draw/private/__quiver__.m @ 32038:29671873411a
__quiver__.m: Honor scaling factor input for single quiver arrow (bug #39552)
* scripts/plot/draw/private/__quiver__.m: Change scaling factor check to
include cases where there is only one quiver arrow.
* etc/NEWS.9.md: Note quiver change under General Improvements.
author | Nicholas R. Jankowski <jankowski.nicholas@gmail.com> |
---|---|
date | Wed, 19 Apr 2023 10:36:29 -0400 |
parents | 597f3ee61a48 |
children | ada96a467a28 |
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 ## |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3 ## Copyright (C) 2007-2023 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27790
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/>. |
7189 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24383
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7189 | 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:
24383
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:
22488
diff
changeset
|
13 ## (at your option) any later version. |
7189 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22488
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22488
diff
changeset
|
18 ## GNU General Public License for more details. |
7189 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
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:
24383
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 ######################################################################## |
7189 | 25 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8532
diff
changeset
|
26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
27 ## @deftypefn {} {@var{hg} =} __quiver__ (@dots{}) |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8532
diff
changeset
|
28 ## Undocumented internal function. |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8532
diff
changeset
|
29 ## @end deftypefn |
7189 | 30 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
31 function hg = __quiver__ (varargin) |
7191 | 32 |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
33 hax = varargin{1}; |
7191 | 34 is3d = varargin{2}; |
7189 | 35 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
36 autoscale = 0.9; |
17671 | 37 ## Matlab uses 0.2, but Octave's algorithm produces equivalent visual |
38 ## results if arrowsize=0.33. Since this is just a non-dimensional | |
39 ## scaling factor we scale the arrowsize property value by 0.33/0.20 | |
40 ## in order to get equivalent visual results while keeping equivalent | |
41 ## property values. | |
42 arrowsize = 0.20; | |
7189 | 43 |
17671 | 44 firstnonnumeric = find (! cellfun ("isnumeric", varargin(3:nargin)), 1); |
45 if (isempty (firstnonnumeric)) | |
46 firstnonnumeric = Inf; | |
47 else | |
48 firstnonnumeric += 2; | |
49 endif | |
7189 | 50 |
51 ioff = 3; | |
52 if (nargin < (6 + is3d) || firstnonnumeric < (6 + is3d)) | |
26831
677764865056
Accept 4-input form for quiver3 (bug #55570).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
53 if (is3d) |
677764865056
Accept 4-input form for quiver3 (bug #55570).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
54 z = varargin{ioff++}; |
677764865056
Accept 4-input form for quiver3 (bug #55570).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
55 endif |
7189 | 56 u = varargin{ioff++}; |
57 v = varargin{ioff++}; | |
58 if (is3d) | |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
59 w = varargin{ioff++}; |
7189 | 60 endif |
27043
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
61 if (is3d) |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
62 if (! size_equal (z, u, v, w)) |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
63 error ("quiver3: Z, U, V, and W must be the same size"); |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
64 endif |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
65 else |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
66 if (! size_equal (u, v)) |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
67 error ("quiver: U and V must be the same size"); |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
68 endif |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
69 endif |
26831
677764865056
Accept 4-input form for quiver3 (bug #55570).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
70 [x, y] = meshgrid (1:columns (u), 1:rows (u)); |
27043
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
71 |
7191 | 72 if (nargin >= ioff && isnumeric (varargin{ioff}) |
10549 | 73 && isscalar (varargin{ioff})) |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
74 autoscale = varargin{ioff++}; |
7189 | 75 endif |
76 else | |
77 x = varargin{ioff++}; | |
78 y = varargin{ioff++}; | |
79 if (is3d) | |
80 z = varargin{ioff++}; | |
81 endif | |
82 u = varargin{ioff++}; | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
83 v = varargin{ioff++}; |
7189 | 84 if (is3d) |
85 w = varargin{ioff++}; | |
7191 | 86 if (isvector (x) && isvector (y) && isvector (z) |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
87 && (! isvector (u) || ! isvector (v) || ! isvector (w))) |
10549 | 88 [x, y, z] = meshgrid (x, y, z); |
7189 | 89 endif |
90 else | |
7191 | 91 if (isvector (x) && isvector (y) && (! isvector (u) || ! isvector (v))) |
10549 | 92 [x, y] = meshgrid (x, y); |
7189 | 93 endif |
94 endif | |
27043
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
95 if (is3d) |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
96 if (! size_equal (x, y, z, u, v, w)) |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
97 error ("quiver3: X, Y, Z, U, V, and W must be the same size"); |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
98 endif |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
99 else |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
100 if (! size_equal (x, y, u, v)) |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
101 error ("quiver: X, Y, U, and V must be the same size"); |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
102 endif |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
103 endif |
7f605f88d1e3
Improve input validation for quiver, quiver3 (bug #56120).
Rik <rik@octave.org>
parents:
26831
diff
changeset
|
104 |
7191 | 105 if (nargin >= ioff && isnumeric (varargin{ioff}) |
10549 | 106 && isscalar (varargin{ioff})) |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
107 autoscale = varargin{ioff++}; |
7189 | 108 endif |
109 endif | |
110 | |
111 have_filled = false; | |
112 have_line_spec = false; | |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
113 args = {}; |
7189 | 114 while (ioff <= nargin) |
7191 | 115 arg = varargin{ioff++}; |
17405
3f0ed69d21c6
Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
116 if (ischar (arg) && strcmpi (arg, "filled")) |
7189 | 117 have_filled = true; |
17462
177147bf7b55
Overhaul use of __pltopt__.m to correctly check for cellstr, not just cell.
Rik <rik@octave.org>
parents:
17405
diff
changeset
|
118 elseif ((ischar (arg) || iscellstr (arg)) |
10549 | 119 && ! have_line_spec) |
7189 | 120 [linespec, valid] = __pltopt__ ("quiver", arg, false); |
121 if (valid) | |
10549 | 122 have_line_spec = true; |
17671 | 123 if (isempty (linespec.linestyle) || strcmp (linespec.linestyle, "none")) |
10549 | 124 linespec.linestyle = "-"; |
125 endif | |
7189 | 126 else |
17671 | 127 args{end+1} = arg; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
128 if (ioff <= nargin) |
17671 | 129 args{end+1} = varargin{ioff++}; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
130 endif |
7189 | 131 endif |
132 else | |
17671 | 133 args{end+1} = arg; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
134 if (ioff <= nargin) |
17671 | 135 args{end+1} = varargin{ioff++}; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
136 endif |
7189 | 137 endif |
138 endwhile | |
139 | |
17671 | 140 ## Normalize 0.20 to 1/3 for plotting |
141 arrowsize /= 0.20 * 3; | |
142 | |
19371
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
143 ## Scale the arrows to fit in the grid |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
144 uu = u; |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
145 vv = v; |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
146 if (is3d) |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
147 ww = w; |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
148 len = max (sqrt (u(:).^2 + v(:).^2 + w(:).^2)); |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
149 else |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19371
diff
changeset
|
150 len = max (sqrt (u(:).^2 + v(:).^2)); |
19371
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
151 endif |
32038
29671873411a
__quiver__.m: Honor scaling factor input for single quiver arrow (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
152 if (len > 0 && autoscale && numel (u) >= 1) |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
153 if (isvector (x)) |
17671 | 154 nx = ny = sqrt (length (x)); |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
155 else |
17671 | 156 [ny, nx] = size (x); # assume meshgrid fmt, x in columns, y in rows |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
157 endif |
17671 | 158 dx = (max (x(:)) - min (x(:))) / nx; |
159 dy = (max (y(:)) - min (y(:))) / ny; | |
7189 | 160 if (is3d) |
17671 | 161 dz = (max (z(:)) - min (z(:))) / max (nx, ny); |
7189 | 162 else |
163 dz = 0; | |
164 endif | |
19371
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
165 sd = sqrt (dx.^2 + dy.^2 + dz.^2) / len; |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
166 if (sd != 0) |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
167 s = autoscale * sd; |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
168 else # special case of identical points with multiple vectors |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
169 s = autoscale; |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
170 endif |
19371
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
171 uu = s * u; |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
172 vv = s * v; |
8315
e9687c313d5f
Fix callbacks in stem and quiver for change in order of children. Fix for scaling in quiver for single arrow
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
173 if (is3d) |
19371
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
174 ww = s * w; |
8315
e9687c313d5f
Fix callbacks in stem and quiver for change in order of children. Fix for scaling in quiver for single arrow
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
175 endif |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
176 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
177 |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
178 hstate = get (hax, "nextplot"); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
179 unwind_protect |
17671 | 180 if (have_line_spec) |
181 ls = linespec.linestyle; | |
182 lc = linespec.color; | |
24382
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
183 if (isempty (lc)) |
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
184 lc = __next_line_color__ (); |
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
185 endif |
17671 | 186 else |
187 ls = "-"; | |
188 lc = __next_line_color__ (); | |
189 endif | |
190 | |
191 ## Must occur after __next_line_color__ in order to work correctly. | |
27790
0157c4d4792e
legend.m: Handle builtin hggroup-based objects (bug #57260)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27106
diff
changeset
|
192 hg = hggroup ("__appdata__", struct ("__creator__", "__quiver__")); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
193 if (is3d) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
194 args = __add_datasource__ ("quiver3", hg, |
10549 | 195 {"x", "y", "z", "u", "v", "w"}, args{:}); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
196 else |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
197 args = __add_datasource__ ("quiver", hg, |
10549 | 198 {"x", "y", "z", "u", "v", "w"}, args{:}); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
199 endif |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
200 |
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
201 hold (hax, "on"); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
202 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
203 addproperty ("xdata", hg, "data", x); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
204 addproperty ("ydata", hg, "data", y); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
205 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
206 addproperty ("udata", hg, "data", u); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
207 addproperty ("vdata", hg, "data", v); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
208 if (is3d) |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
209 addproperty ("zdata", hg, "data", z); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
210 addproperty ("wdata", hg, "data", w); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
211 else |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
212 addproperty ("zdata", hg, "data", []); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
213 addproperty ("wdata", hg, "data", []); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
214 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
215 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
216 addlistener (hg, "xdata", @update_data); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
217 addlistener (hg, "ydata", @update_data); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
218 addlistener (hg, "zdata", @update_data); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
219 addlistener (hg, "udata", @update_data); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
220 addlistener (hg, "vdata", @update_data); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
221 addlistener (hg, "wdata", @update_data); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
222 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
223 x = x(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
224 y = y(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
225 xend = x + uu(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
226 yend = y + vv(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
227 if (is3d) |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
228 z = z(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
229 zend = z + ww(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
230 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
231 |
17671 | 232 ## Draw arrow shaft as one line object |
233 if (is3d) | |
234 h1 = plot3 ([x.'; xend.'; NaN(1, length (x))](:), | |
235 [y.'; yend.'; NaN(1, length (y))](:), | |
236 [z.'; zend.'; NaN(1, length (z))](:), | |
237 "linestyle", ls, "color", lc, "parent", hg); | |
238 else | |
239 h1 = plot ([x.'; xend.'; NaN(1, length (x))](:), | |
240 [y.'; yend.'; NaN(1, length (y))](:), | |
241 "linestyle", ls, "color", lc, "parent", hg); | |
242 endif | |
243 | |
244 xtmp = x + uu(:) * (1 - arrowsize); | |
245 ytmp = y + vv(:) * (1 - arrowsize); | |
246 | |
247 if (is3d) | |
248 xydist = sqrt (uu(:).^2 + vv(:).^2 + ww(:).^2) ./ ... | |
249 (sqrt (uu(:).^2 + vv(:).^2) + eps); | |
250 xarrw1 = xtmp + vv(:) .* xydist * arrowsize / 4; | |
251 xarrw2 = xtmp - vv(:) .* xydist * arrowsize / 4; | |
252 yarrw1 = ytmp - uu(:) .* xydist * arrowsize / 4; | |
253 yarrw2 = ytmp + uu(:) .* xydist * arrowsize / 4; | |
254 zarrw1 = zarrw2 = zend - ww(:) * arrowsize; | |
255 else | |
256 xarrw1 = xtmp + vv(:) * arrowsize / 3; | |
257 xarrw2 = xtmp - vv(:) * arrowsize / 3; | |
258 yarrw1 = ytmp - uu(:) * arrowsize / 3; | |
259 yarrw2 = ytmp + uu(:) * arrowsize / 3; | |
260 endif | |
261 | |
262 ## Draw arrowhead as one line object | |
24382
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
263 |
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
264 ## Arrowhead is constructed, but NOT displayed, when marker is present. |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
265 if (have_line_spec) |
17671 | 266 if (! isempty (linespec.marker) && ! strcmp (linespec.marker, "none")) |
24382
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
267 ls = "none"; |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
268 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
269 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
270 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
271 if (is3d) |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
272 h2 = plot3 ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:), |
10549 | 273 [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:), |
274 [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:), | |
17671 | 275 "linestyle", ls, "color", lc, "parent", hg); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
276 else |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
277 h2 = plot ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:), |
10549 | 278 [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:), |
17671 | 279 "linestyle", ls, "color", lc, "parent", hg); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
280 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
281 |
17671 | 282 ## Draw arrow base marker as a third line object |
283 if (! have_line_spec || isempty (linespec.marker)) | |
284 mk = "none"; | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
285 else |
17671 | 286 mk = linespec.marker; |
287 endif | |
288 if (is3d) | |
24382
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
289 h3 = plot3 (x, y, z, "linestyle", "none", "color", lc, "marker", mk, |
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
290 "parent", hg); |
17671 | 291 else |
24382
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
292 h3 = plot (x, y, "linestyle", "none", "color", lc, "marker", mk, |
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
293 "parent", hg); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
294 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
295 if (have_filled) |
24382
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
296 set (h3, "markerfacecolor", lc); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
297 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
298 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
299 ## Set up the hggroup properties and listeners |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
300 if (autoscale) |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
301 addproperty ("autoscale", hg, "radio", "{on}|off", "on"); |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
302 addproperty ("autoscalefactor", hg, "data", autoscale); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
303 else |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
304 addproperty ("autoscale", hg, "radio", "{on}|off", "off"); |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
305 addproperty ("autoscalefactor", hg, "data", 1.0); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
306 endif |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
307 addlistener (hg, "autoscale", @update_data); |
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
308 addlistener (hg, "autoscalefactor", @update_data); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
309 |
17671 | 310 addproperty ("maxheadsize", hg, "data", arrowsize * .20*3); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
311 addlistener (hg, "maxheadsize", @update_data); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
312 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
313 addproperty ("showarrowhead", hg, "radio", "{on}|off", "on"); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
314 addlistener (hg, "showarrowhead", @update_props); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
315 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
316 addproperty ("color", hg, "linecolor", get (h1, "color")); |
17671 | 317 addproperty ("linestyle", hg, "linelinestyle", get (h1, "linestyle")); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
318 addproperty ("linewidth", hg, "linelinewidth", get (h1, "linewidth")); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
319 addproperty ("marker", hg, "linemarker", get (h3, "marker")); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
320 addproperty ("markerfacecolor", hg, "linemarkerfacecolor", |
10549 | 321 get (h3, "markerfacecolor")); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
322 addproperty ("markersize", hg, "linemarkersize", get (h3, "markersize")); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
323 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
324 addlistener (hg, "color", @update_props); |
17671 | 325 addlistener (hg, "linestyle", @update_props); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
326 addlistener (hg, "linewidth", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
327 addlistener (hg, "marker", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
328 addlistener (hg, "markerfacecolor", @update_props); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
329 addlistener (hg, "markersize", @update_props); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
330 |
17527
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
331 ## Matlab property, although Octave does not implement it. |
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
332 addproperty ("hittestarea", hg, "radio", "on|{off}", "off"); |
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
333 |
8079
082fa7859574
Additional do not call set with empty arguments fixes
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
334 if (! isempty (args)) |
082fa7859574
Additional do not call set with empty arguments fixes
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
335 set (hg, args{:}); |
082fa7859574
Additional do not call set with empty arguments fixes
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
336 endif |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
337 unwind_protect_cleanup |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
338 set (hax, "nextplot", hstate); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
339 end_unwind_protect |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
340 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
341 endfunction |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
342 |
17671 | 343 function update_data (h, ~) |
344 | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
345 x = get (h, "xdata"); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
346 y = get (h, "ydata"); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
347 z = get (h, "zdata"); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
348 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
349 u = get (h, "udata"); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
350 v = get (h, "vdata"); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
351 w = get (h, "wdata"); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
352 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
353 s = get (h, "autoscalefactor"); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
354 arrowsize = get (h, "maxheadsize"); |
17671 | 355 arrowsize /= 0.20 * 3; |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
356 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
357 kids = get (h, "children"); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
358 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
359 if (isempty (z) || isempty (w)) |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
360 is3d = false; |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
361 else |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
362 is3d = true; |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
363 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
364 |
17671 | 365 if (strcmp (get (h, "autoscale"), "on") && s != 0) |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
366 ## Scale the arrows to fit in the grid |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
367 if (isvector (x)) |
17671 | 368 nx = ny = sqrt (length (x)); |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
369 else |
17671 | 370 [ny, nx] = size (x); |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
371 endif |
17671 | 372 dx = (max (x(:)) - min (x(:))) / nx; |
373 dy = (max (y(:)) - min (y(:))) / ny; | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
374 if (is3d) |
17671 | 375 dz = (max (z(:)) - min (z(:))) / max (nx, ny); |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
376 len = max (sqrt (u(:).^2 + v(:).^2 + w(:).^2)); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
377 else |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
378 dz = 0; |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
379 len = max (sqrt (u(:).^2 + v(:).^2)); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
380 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
381 if (len > 0) |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
382 sd = sqrt (dx.^2 + dy.^2 + dz.^2) / len; |
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
383 if (sd != 0) |
17671 | 384 s *= sd; |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
385 endif |
7189 | 386 u = s * u; |
387 v = s * v; | |
388 if (is3d) | |
17671 | 389 w = s * w; |
7189 | 390 endif |
391 endif | |
392 endif | |
393 | |
394 x = x(:); | |
395 y = y(:); | |
396 xend = x + u(:); | |
397 yend = y + v(:); | |
398 if (is3d) | |
399 z = z(:); | |
400 zend = z + w(:); | |
401 endif | |
402 | |
27106
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
27043
diff
changeset
|
403 set (kids(3), "xdata", [x.'; xend.'; NaN(1, length (x))](:), |
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
27043
diff
changeset
|
404 "ydata", [y.'; yend.'; NaN(1, length (y))](:)); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
405 if (is3d) |
17671 | 406 set (kids(3), "zdata", [z.'; zend.'; NaN(1, length (z))](:)); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
407 endif |
7189 | 408 |
17671 | 409 xtmp = x + u(:) * (1 - arrowsize); |
410 ytmp = y + v(:) * (1 - arrowsize); | |
411 | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
412 if (is3d) |
17671 | 413 xydist = sqrt (u(:).^2 + v(:).^2 + w(:).^2) ./ ... |
414 (sqrt (u(:).^2 + v(:).^2) + eps); | |
415 xarrw1 = xtmp + v(:) .* xydist * arrowsize / 4; | |
416 xarrw2 = xtmp - v(:) .* xydist * arrowsize / 4; | |
417 yarrw1 = ytmp - u(:) .* xydist * arrowsize / 4; | |
418 yarrw2 = ytmp + u(:) .* xydist * arrowsize / 4; | |
419 zarrw1 = zarrw2 = zend - w(:) * arrowsize; | |
420 else | |
421 xarrw1 = xtmp + v(:) * arrowsize / 3; | |
422 xarrw2 = xtmp - v(:) * arrowsize / 3; | |
423 yarrw1 = ytmp - u(:) * arrowsize / 3; | |
424 yarrw2 = ytmp + u(:) * arrowsize / 3; | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
425 endif |
7189 | 426 |
27106
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
27043
diff
changeset
|
427 set (kids(2), "xdata", [x.'; xend.'; NaN(1, length (x))](:), |
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
27043
diff
changeset
|
428 "ydata", [y.'; yend.'; NaN(1, length (y))](:)); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
429 if (is3d) |
17671 | 430 set (kids(2), "zdata", [z.'; zend.'; NaN(1, length (z))](:)); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
431 endif |
7189 | 432 |
27106
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
27043
diff
changeset
|
433 set (kids(2), "xdata", [xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:), |
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
27043
diff
changeset
|
434 "ydata", [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:)); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
435 if (is3d) |
17671 | 436 set (kids(2), "zdata", [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:)); |
437 endif | |
438 | |
27106
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
27043
diff
changeset
|
439 set (kids(1), "xdata", x, "ydata", y); |
17671 | 440 if (is3d) |
441 set (kids(1), "zdata", z); | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
442 endif |
7189 | 443 |
444 endfunction | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
445 |
17671 | 446 function update_props (h, ~) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
447 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
448 kids = get (h, "children"); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
449 |
17671 | 450 set (kids([3 2]), {"color", "linestyle", "linewidth"}, |
451 get (h, {"color", "linestyle", "linewidth"})); | |
452 set (kids(2), "visible", get (h, "showarrowhead")); | |
453 set (kids(1), {"color", "marker", "markerfacecolor", "markersize"}, | |
454 get (h, {"color", "marker", "markerfacecolor", "markersize"})); | |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
455 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
456 endfunction |