Mercurial > octave
annotate scripts/plot/draw/private/__quiver__.m @ 32084:7dcb6b4a4218
quiver: Marker & arrowhead name/value property style consistency (bug #64134)
* __quiver__.m: Add have_line_spec check after applying any name-value
properties to maintain arrowhead display status.
* __quiver__.m (update_plot): Add linewidth property to base marker object
set call.
* quiver.m: Add BIST to ensure marker properties are updated correctly.
Remove unnecessary strcmp from other BIST assert calls.
* etc/NEWS.9.md: Update description of changes to quiver note under General
Improvements.
author | Nicholas R. Jankowski <jankowski.nicholas@gmail.com> |
---|---|
date | Mon, 08 May 2023 11:49:41 -0400 |
parents | 03fe0b635d2e |
children | 2e484f9f1f18 |
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 |
32074
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
31 function [hax, hg]= __quiver__ (varargin) |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
32 hax = varargin{1}; |
7191 | 33 is3d = varargin{2}; |
7189 | 34 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
35 autoscale = 0.9; |
17671 | 36 ## Matlab uses 0.2, but Octave's algorithm produces equivalent visual |
37 ## results if arrowsize=0.33. Since this is just a non-dimensional | |
38 ## scaling factor we scale the arrowsize property value by 0.33/0.20 | |
39 ## in order to get equivalent visual results while keeping equivalent | |
40 ## property values. | |
41 arrowsize = 0.20; | |
32074
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
42 lastnumeric = find (cellfun ("ischar", varargin(3:nargin)), 1) - 1; |
32062
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32038
diff
changeset
|
43 |
32074
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
44 if (isempty (lastnumeric)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
45 lastnumeric = nargin; |
32062
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32038
diff
changeset
|
46 ## Recast non-float inputs as doubles to avoid erroneous plots. |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32038
diff
changeset
|
47 varargin(3:end) = cellfun ('double', varargin(3:end), ... |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32038
diff
changeset
|
48 "UniformOutput", false); |
17671 | 49 else |
32062
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32038
diff
changeset
|
50 |
32074
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
51 lastnumeric += 2; |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
52 ## Recast non-float inputs as doubles to avoid erroneous plots. |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
53 varargin(3:lastnumeric) = cellfun ('double', |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
54 varargin(3:lastnumeric), "UniformOutput", false); |
32062
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32038
diff
changeset
|
55 |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32038
diff
changeset
|
56 ## Check for scaling factor "off" and set it to 0. |
32074
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
57 if ((nargin > lastnumeric) && strcmpi (varargin{lastnumeric+1}, "off")) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
58 varargin(++lastnumeric) = 0; |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
59 endif |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
60 endif |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
61 |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
62 if (is3d) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
63 ## quiver3 3D input validation. |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
64 switch (lastnumeric) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
65 case {6,7} |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
66 [z, u, v, w] = deal (varargin{3:6}); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
67 if (isvector (z) && ! isvector (u)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
68 if (! size_equal (u, v, w)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
69 error ("quiver3: U, V, and W must be the same size"); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
70 elseif (numel(z) != size (u, 3)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
71 error (["quiver3: Z vector length must equal size of ", ... |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
72 "U, V, and W in dim 3"]); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
73 endif |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
74 [x, y, z] = meshgrid (1 : columns (u), 1 : rows (u), z); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
75 else |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
76 if (! size_equal (z, u, v, w)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
77 error ("quiver3: Z, U, V, and W must be the same size"); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
78 endif |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
79 [x, y] = meshgrid (1 : columns (u), 1 : rows (u), 1:size (u, 3)); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
80 endif |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
81 |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
82 case {8,9} |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
83 [x, y, z, u, v, w] = deal (varargin{3:8}); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
84 if (isvector (x) && isvector (y) && isvector (z) && ! isvector (u)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
85 if (! size_equal (u, v, w)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
86 error ("quiver3: U, V, and W must be the same size"); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
87 elseif (numel(x) != columns (u)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
88 error (["quiver3: X vector length must equal number of ", ... |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
89 "columns in U, V, and W"]); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
90 elseif (numel(y) != rows (u)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
91 error (["quiver3: Y vector length must equal number of ", ... |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
92 "rows in U, V, and W"]); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
93 elseif (numel(z) != size (u, 3)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
94 error (["quiver3: Z vector length must equal size of ", ... |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
95 "U, V, and W in dim 3"]); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
96 endif |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
97 [x, y, z] = meshgrid (x, y, z); |
32062
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32038
diff
changeset
|
98 |
32074
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
99 elseif (! size_equal (x, y, z, u, v, w)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
100 error ("quiver3: X, Y, Z, U, V, and W must be the same size"); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
101 endif |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
102 otherwise |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
103 ## too few or too many numeric inputs before first style input |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
104 print_usage ("quiver3"); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
105 endswitch |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
106 |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
107 else |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
108 ## quiver 2D input validation. |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
109 switch (lastnumeric) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
110 case {4,5} |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
111 [u, v] = deal (varargin{3:4}); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
112 if (! size_equal (u, v)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
113 error ("quiver: U and V must be the same size"); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
114 endif |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
115 [x, y] = meshgrid (1:columns (u), 1:rows (u)); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
116 |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
117 case {6,7} # |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
118 [x, y, u, v] = deal (varargin{3:6}); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
119 |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
120 if (isvector (x) && isvector (y) && ... |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
121 (! isvector (u) || ! isvector (v) )) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
122 if (! size_equal (u, v)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
123 error ("quiver: U and V must be the same size"); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
124 elseif (numel (x) != columns (u)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
125 error (["quiver: X vector length must equal number of ", ... |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
126 "columns in U and V"]); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
127 elseif (numel (y) != rows (u)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
128 error (["quiver: Y vector length must equal number of ", ... |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
129 "rows in U and V"]); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
130 endif |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
131 [x, y] = meshgrid (x, y); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
132 elseif (! size_equal (x, y, u, v)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
133 error ("quiver: X, Y, U, and V must be the same size"); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
134 endif |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
135 otherwise |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
136 ## too few or too many numeric inputs before first style input |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
137 print_usage ("quiver"); |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
138 endswitch |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
139 endif |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
140 |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
141 if (rem (lastnumeric, 2)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
142 autoscale = varargin{lastnumeric}; # Last odd input is scale factor. |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
143 |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
144 if (autoscale < 0 || ! isscalar (autoscale)) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
145 if (is3d) |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
146 error (["quiver3: scaling factor must be a non-negative scalar ", ... |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
147 "or 'off'"]); |
32062
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32038
diff
changeset
|
148 else |
32074
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
149 error (["quiver: scaling factor must be a non-negative scalar ", ... |
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
150 "or 'off'"]); |
32062
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32038
diff
changeset
|
151 endif |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32038
diff
changeset
|
152 endif |
17671 | 153 endif |
7189 | 154 |
32074
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
155 ioff = lastnumeric + 1; |
7189 | 156 have_filled = false; |
157 have_line_spec = false; | |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
158 args = {}; |
7189 | 159 while (ioff <= nargin) |
7191 | 160 arg = varargin{ioff++}; |
17405
3f0ed69d21c6
Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
161 if (ischar (arg) && strcmpi (arg, "filled")) |
7189 | 162 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
|
163 elseif ((ischar (arg) || iscellstr (arg)) |
10549 | 164 && ! have_line_spec) |
7189 | 165 [linespec, valid] = __pltopt__ ("quiver", arg, false); |
166 if (valid) | |
10549 | 167 have_line_spec = true; |
17671 | 168 if (isempty (linespec.linestyle) || strcmp (linespec.linestyle, "none")) |
10549 | 169 linespec.linestyle = "-"; |
170 endif | |
7189 | 171 else |
17671 | 172 args{end+1} = arg; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
173 if (ioff <= nargin) |
17671 | 174 args{end+1} = varargin{ioff++}; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
175 endif |
7189 | 176 endif |
177 else | |
17671 | 178 args{end+1} = arg; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
179 if (ioff <= nargin) |
17671 | 180 args{end+1} = varargin{ioff++}; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
181 endif |
7189 | 182 endif |
183 endwhile | |
184 | |
17671 | 185 ## Normalize 0.20 to 1/3 for plotting |
186 arrowsize /= 0.20 * 3; | |
187 | |
19371
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
188 ## 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
|
189 uu = u; |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
190 vv = v; |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
191 if (is3d) |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
192 ww = w; |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
193 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
|
194 else |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19371
diff
changeset
|
195 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
|
196 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
|
197 if (len > 0 && autoscale && numel (u) >= 1) |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
198 if (isvector (x)) |
17671 | 199 nx = ny = sqrt (length (x)); |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
200 else |
17671 | 201 [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
|
202 endif |
17671 | 203 dx = (max (x(:)) - min (x(:))) / nx; |
204 dy = (max (y(:)) - min (y(:))) / ny; | |
7189 | 205 if (is3d) |
17671 | 206 dz = (max (z(:)) - min (z(:))) / max (nx, ny); |
7189 | 207 else |
208 dz = 0; | |
209 endif | |
19371
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
210 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
|
211 if (sd != 0) |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
212 s = autoscale * sd; |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
213 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
|
214 s = autoscale; |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
215 endif |
19371
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
216 uu = s * u; |
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
217 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
|
218 if (is3d) |
19371
009191dbc76d
quiver: fix initialization error when called with zeros (bug #43686)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
219 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
|
220 endif |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
221 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
222 |
32074
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
223 hax = newplot (hax); |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
224 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
|
225 unwind_protect |
17671 | 226 if (have_line_spec) |
227 ls = linespec.linestyle; | |
228 lc = linespec.color; | |
24382
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
229 if (isempty (lc)) |
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
230 lc = __next_line_color__ (); |
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
231 endif |
17671 | 232 else |
233 ls = "-"; | |
234 lc = __next_line_color__ (); | |
235 endif | |
236 | |
237 ## 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
|
238 hg = hggroup ("__appdata__", struct ("__creator__", "__quiver__")); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
239 if (is3d) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
240 args = __add_datasource__ ("quiver3", hg, |
10549 | 241 {"x", "y", "z", "u", "v", "w"}, args{:}); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
242 else |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
243 args = __add_datasource__ ("quiver", hg, |
10549 | 244 {"x", "y", "z", "u", "v", "w"}, args{:}); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
245 endif |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
246 |
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
247 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
|
248 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
249 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
|
250 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
|
251 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
252 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
|
253 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
|
254 if (is3d) |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
255 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
|
256 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
|
257 else |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
258 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
|
259 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
|
260 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
261 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
262 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
269 x = x(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
270 y = y(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
271 xend = x + uu(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
272 yend = y + vv(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
273 if (is3d) |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
274 z = z(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
275 zend = z + ww(:); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
276 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
277 |
17671 | 278 ## Draw arrow shaft as one line object |
279 if (is3d) | |
280 h1 = plot3 ([x.'; xend.'; NaN(1, length (x))](:), | |
281 [y.'; yend.'; NaN(1, length (y))](:), | |
282 [z.'; zend.'; NaN(1, length (z))](:), | |
283 "linestyle", ls, "color", lc, "parent", hg); | |
284 else | |
285 h1 = plot ([x.'; xend.'; NaN(1, length (x))](:), | |
286 [y.'; yend.'; NaN(1, length (y))](:), | |
287 "linestyle", ls, "color", lc, "parent", hg); | |
288 endif | |
289 | |
290 xtmp = x + uu(:) * (1 - arrowsize); | |
291 ytmp = y + vv(:) * (1 - arrowsize); | |
292 | |
293 if (is3d) | |
294 xydist = sqrt (uu(:).^2 + vv(:).^2 + ww(:).^2) ./ ... | |
295 (sqrt (uu(:).^2 + vv(:).^2) + eps); | |
296 xarrw1 = xtmp + vv(:) .* xydist * arrowsize / 4; | |
297 xarrw2 = xtmp - vv(:) .* xydist * arrowsize / 4; | |
298 yarrw1 = ytmp - uu(:) .* xydist * arrowsize / 4; | |
299 yarrw2 = ytmp + uu(:) .* xydist * arrowsize / 4; | |
300 zarrw1 = zarrw2 = zend - ww(:) * arrowsize; | |
301 else | |
302 xarrw1 = xtmp + vv(:) * arrowsize / 3; | |
303 xarrw2 = xtmp - vv(:) * arrowsize / 3; | |
304 yarrw1 = ytmp - uu(:) * arrowsize / 3; | |
305 yarrw2 = ytmp + uu(:) * arrowsize / 3; | |
306 endif | |
307 | |
308 ## 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
|
309 |
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
310 ## 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
|
311 if (have_line_spec) |
17671 | 312 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
|
313 ls = "none"; |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
314 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
315 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
316 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
317 if (is3d) |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
318 h2 = plot3 ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:), |
10549 | 319 [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:), |
320 [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:), | |
17671 | 321 "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
|
322 else |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
323 h2 = plot ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:), |
10549 | 324 [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:), |
17671 | 325 "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
|
326 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
327 |
17671 | 328 ## Draw arrow base marker as a third line object |
329 if (! have_line_spec || isempty (linespec.marker)) | |
330 mk = "none"; | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
331 else |
17671 | 332 mk = linespec.marker; |
333 endif | |
334 if (is3d) | |
24382
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
335 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
|
336 "parent", hg); |
17671 | 337 else |
24382
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
338 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
|
339 "parent", hg); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
340 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
341 if (have_filled) |
24382
b71ba49473f4
Fix incorrect color of markers in quiver plots when linestyle given.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
342 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
|
343 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
344 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
345 ## 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
|
346 if (autoscale) |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
347 addproperty ("autoscale", hg, "radio", "{on}|off", "on"); |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
348 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
|
349 else |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
350 addproperty ("autoscale", hg, "radio", "{on}|off", "off"); |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
351 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
|
352 endif |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
353 addlistener (hg, "autoscale", @update_data); |
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
354 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
|
355 |
17671 | 356 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
|
357 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
|
358 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
359 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
|
360 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
|
361 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
362 addproperty ("color", hg, "linecolor", get (h1, "color")); |
17671 | 363 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
|
364 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
|
365 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
|
366 addproperty ("markerfacecolor", hg, "linemarkerfacecolor", |
10549 | 367 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
|
368 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
|
369 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
370 addlistener (hg, "color", @update_props); |
17671 | 371 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
|
372 addlistener (hg, "linewidth", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
373 addlistener (hg, "marker", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
374 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
|
375 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
|
376 |
17527
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
377 ## 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
|
378 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
|
379 |
8079
082fa7859574
Additional do not call set with empty arguments fixes
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
380 if (! isempty (args)) |
082fa7859574
Additional do not call set with empty arguments fixes
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
381 set (hg, args{:}); |
32084
7dcb6b4a4218
quiver: Marker & arrowhead name/value property style consistency (bug #64134)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32074
diff
changeset
|
382 if (have_line_spec && ! isempty (linespec.marker) && ... |
7dcb6b4a4218
quiver: Marker & arrowhead name/value property style consistency (bug #64134)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32074
diff
changeset
|
383 ! strcmp (linespec.marker, "none")) |
7dcb6b4a4218
quiver: Marker & arrowhead name/value property style consistency (bug #64134)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32074
diff
changeset
|
384 set (h2, "linestyle", "none"); |
7dcb6b4a4218
quiver: Marker & arrowhead name/value property style consistency (bug #64134)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32074
diff
changeset
|
385 endif |
8079
082fa7859574
Additional do not call set with empty arguments fixes
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
386 endif |
32074
03fe0b635d2e
quiver/quiver3: Overhaul input processing, validation, and add BISTs.
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32062
diff
changeset
|
387 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
388 unwind_protect_cleanup |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
389 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
|
390 end_unwind_protect |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
391 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
392 endfunction |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
393 |
17671 | 394 function update_data (h, ~) |
395 | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
396 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
|
397 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
|
398 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
|
399 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
400 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
|
401 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
|
402 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
|
403 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
404 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
|
405 arrowsize = get (h, "maxheadsize"); |
17671 | 406 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
|
407 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
408 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
|
409 |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
410 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
|
411 is3d = false; |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
412 else |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
413 is3d = true; |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
414 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
415 |
17671 | 416 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
|
417 ## 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
|
418 if (isvector (x)) |
17671 | 419 nx = ny = sqrt (length (x)); |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
420 else |
17671 | 421 [ny, nx] = size (x); |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
422 endif |
17671 | 423 dx = (max (x(:)) - min (x(:))) / nx; |
424 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
|
425 if (is3d) |
17671 | 426 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
|
427 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
|
428 else |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
429 dz = 0; |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
430 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
|
431 endif |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
432 if (len > 0) |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
433 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
|
434 if (sd != 0) |
17671 | 435 s *= sd; |
12554
4040a95a586d
Revamp quiver autoscaling algorithm (bug #32836).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
436 endif |
7189 | 437 u = s * u; |
438 v = s * v; | |
439 if (is3d) | |
17671 | 440 w = s * w; |
7189 | 441 endif |
442 endif | |
443 endif | |
444 | |
445 x = x(:); | |
446 y = y(:); | |
447 xend = x + u(:); | |
448 yend = y + v(:); | |
449 if (is3d) | |
450 z = z(:); | |
451 zend = z + w(:); | |
452 endif | |
453 | |
27106
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
27043
diff
changeset
|
454 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
|
455 "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
|
456 if (is3d) |
17671 | 457 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
|
458 endif |
7189 | 459 |
17671 | 460 xtmp = x + u(:) * (1 - arrowsize); |
461 ytmp = y + v(:) * (1 - arrowsize); | |
462 | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
463 if (is3d) |
17671 | 464 xydist = sqrt (u(:).^2 + v(:).^2 + w(:).^2) ./ ... |
465 (sqrt (u(:).^2 + v(:).^2) + eps); | |
466 xarrw1 = xtmp + v(:) .* xydist * arrowsize / 4; | |
467 xarrw2 = xtmp - v(:) .* xydist * arrowsize / 4; | |
468 yarrw1 = ytmp - u(:) .* xydist * arrowsize / 4; | |
469 yarrw2 = ytmp + u(:) .* xydist * arrowsize / 4; | |
470 zarrw1 = zarrw2 = zend - w(:) * arrowsize; | |
471 else | |
472 xarrw1 = xtmp + v(:) * arrowsize / 3; | |
473 xarrw2 = xtmp - v(:) * arrowsize / 3; | |
474 yarrw1 = ytmp - u(:) * arrowsize / 3; | |
475 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
|
476 endif |
7189 | 477 |
27106
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
27043
diff
changeset
|
478 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
|
479 "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
|
480 if (is3d) |
17671 | 481 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
|
482 endif |
7189 | 483 |
27106
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
27043
diff
changeset
|
484 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
|
485 "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
|
486 if (is3d) |
17671 | 487 set (kids(2), "zdata", [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:)); |
488 endif | |
489 | |
27106
6bfd3a890185
Consolidate separate calls to set() in to one call for interpreter efficiency.
Rik <rik@octave.org>
parents:
27043
diff
changeset
|
490 set (kids(1), "xdata", x, "ydata", y); |
17671 | 491 if (is3d) |
492 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
|
493 endif |
7189 | 494 |
495 endfunction | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
496 |
17671 | 497 function update_props (h, ~) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
498 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
499 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
|
500 |
17671 | 501 set (kids([3 2]), {"color", "linestyle", "linewidth"}, |
502 get (h, {"color", "linestyle", "linewidth"})); | |
503 set (kids(2), "visible", get (h, "showarrowhead")); | |
32084
7dcb6b4a4218
quiver: Marker & arrowhead name/value property style consistency (bug #64134)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32074
diff
changeset
|
504 set (kids(1), {"color", "marker", "markerfacecolor", "markersize", ... |
7dcb6b4a4218
quiver: Marker & arrowhead name/value property style consistency (bug #64134)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32074
diff
changeset
|
505 "linewidth"}, get (h, {"color", "marker", "markerfacecolor", ... |
7dcb6b4a4218
quiver: Marker & arrowhead name/value property style consistency (bug #64134)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32074
diff
changeset
|
506 "markersize", "linewidth"})); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
507 |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
508 endfunction |