Mercurial > octave
annotate scripts/plot/draw/quiver.m @ 32062:ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
* scripts/plot/draw/private/__quiver__.m: Change firstnonnumeric check to look
for char instead of numeric to allow for logical inputs. Recast all inputs
up to firstnonnumeric as doubles. Check if firstnonnumeric element is 'off'
and if so set scale factor to 0 and increment firstnonnumeric.
* scripts/plot/draw/quiver.m: Update docstring to include scaling factor
option 'off'. Add BIST for int and logical input types.
* scripts/plot/draw/quiver3.m: Update docstring to include scaling factor
option 'off'. Add BISTs for too-few inputs.
* etc/NEWS.9.md: Appended details of changes to quiver note under General
Improvements and noted it also applies to quiver3.
author | Nicholas R. Jankowski <jankowski.nicholas@gmail.com> |
---|---|
date | Wed, 26 Apr 2023 17:18:50 -0400 |
parents | 31f7f5359ba2 |
children | 03fe0b635d2e |
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:
26376
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/>. |
7120 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24432
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7120 | 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:
24432
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:
22366
diff
changeset
|
13 ## (at your option) any later version. |
7120 | 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:
22366
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22366
diff
changeset
|
18 ## GNU General Public License for more details. |
7120 | 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:
24432
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 ######################################################################## |
7120 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
27 ## @deftypefn {} {} quiver (@var{u}, @var{v}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
28 ## @deftypefnx {} {} quiver (@var{x}, @var{y}, @var{u}, @var{v}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
29 ## @deftypefnx {} {} quiver (@dots{}, @var{s}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
30 ## @deftypefnx {} {} quiver (@dots{}, @var{style}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
31 ## @deftypefnx {} {} quiver (@dots{}, "filled") |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
32 ## @deftypefnx {} {} quiver (@var{hax}, @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
33 ## @deftypefnx {} {@var{h} =} quiver (@dots{}) |
7120 | 34 ## |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
35 ## Plot a 2-D vector field with arrows. |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
36 ## |
24381
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
37 ## Plot the (@var{u}, @var{v}) components of a vector field at the grid points |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
38 ## defined by (@var{x}, @var{y}). If the grid is uniform then @var{x} and |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
39 ## @var{y} can be specified as vectors and @code{meshgrid} is used to create |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
40 ## the 2-D grid. |
7120 | 41 ## |
24381
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
42 ## If @var{x} and @var{y} are not given they are assumed to be |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
43 ## @code{(1:@var{m}, 1:@var{n})} where |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
44 ## @code{[@var{m}, @var{n}] = size (@var{u})}. |
7120 | 45 ## |
24381
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
46 ## The optional input @var{s} is a scalar defining a scaling factor to use for |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
47 ## the arrows of the field relative to the mesh spacing. A value of 1.0 will |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
48 ## result in the longest vector exactly filling one grid square. A value of 0 |
32062
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
49 ## or "off" disables all scaling. The default value is 0.9. |
7120 | 50 ## |
51 ## The style to use for the plot can be defined with a line style @var{style} | |
24381
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
52 ## of the same format as the @code{plot} command. If a marker is specified |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
53 ## then the markers are drawn at the origin of the vectors (which are the grid |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
54 ## points defined by @var{x} and @var{y}). When a marker is specified, the |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
55 ## arrowhead is not drawn. If the argument @qcode{"filled"} is given then the |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
56 ## markers are filled. |
7120 | 57 ## |
24431
0c6cedafc71e
doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents:
24381
diff
changeset
|
58 ## If the first argument @var{hax} is an axes handle, then plot into this axes, |
17161
52931d71400f
doc: Document that first argument can be an axes handle for several plot functions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
59 ## rather than the current axes returned by @code{gca}. |
52931d71400f
doc: Document that first argument can be an axes handle for several plot functions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
60 ## |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
61 ## The optional return value @var{h} is a graphics handle to a quiver object. |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
62 ## A quiver object regroups the components of the quiver plot (body, arrow, |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
63 ## and marker), and allows them to be changed together. |
7120 | 64 ## |
17671 | 65 ## Example: |
66 ## | |
7121 | 67 ## @example |
7120 | 68 ## @group |
7121 | 69 ## [x, y] = meshgrid (1:2:20); |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7215
diff
changeset
|
70 ## h = quiver (x, y, sin (2*pi*x/10), sin (2*pi*y/10)); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7215
diff
changeset
|
71 ## set (h, "maxheadsize", 0.33); |
7121 | 72 ## @end group |
7120 | 73 ## @end example |
74 ## | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
75 ## @seealso{quiver3, compass, feather, plot} |
7120 | 76 ## @end deftypefn |
77 | |
17671 | 78 function h = quiver (varargin) |
7121 | 79 |
17070
d465f9970c02
quiver.m, quiver3.m: Upgrade to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
80 [hax, varargin, nargin] = __plt_get_axis_arg__ ("quiver", varargin{:}); |
7215 | 81 |
7120 | 82 if (nargin < 2) |
83 print_usage (); | |
17671 | 84 endif |
85 | |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17161
diff
changeset
|
86 oldfig = []; |
17301
68bcac3c043a
Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
87 if (! isempty (hax)) |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17161
diff
changeset
|
88 oldfig = get (0, "currentfigure"); |
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17161
diff
changeset
|
89 endif |
17671 | 90 unwind_protect |
91 hax = newplot (hax); | |
92 htmp = __quiver__ (hax, false, varargin{:}); | |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
93 |
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
94 ## FIXME: This should be moved into __quiver__ when problem with |
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
95 ## re-initialization of title object is fixed. |
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
96 if (! ishold ()) |
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
97 set (hax, "box", "on"); |
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
98 endif |
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
99 |
17671 | 100 unwind_protect_cleanup |
17070
d465f9970c02
quiver.m, quiver3.m: Upgrade to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
101 if (! isempty (oldfig)) |
d465f9970c02
quiver.m, quiver3.m: Upgrade to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
102 set (0, "currentfigure", oldfig); |
d465f9970c02
quiver.m, quiver3.m: Upgrade to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
103 endif |
17671 | 104 end_unwind_protect |
7120 | 105 |
106 if (nargout > 0) | |
17671 | 107 h = htmp; |
7120 | 108 endif |
7121 | 109 |
7120 | 110 endfunction |
111 | |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
112 |
7120 | 113 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
114 %! clf; |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
115 %! [x,y] = meshgrid (1:2:20); |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
116 %! h = quiver (x,y, sin (2*pi*x/10), sin (2*pi*y/10)); |
24381
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
117 %! title ("quiver() plot w/arrowheads (default)"); |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
118 |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
119 %!demo |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
120 %! clf; |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
121 %! [x,y] = meshgrid (1:2:20); |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
122 %! h = quiver (x,y, sin (2*pi*x/10), sin (2*pi*y/10), "o"); |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
123 %! title ("quiver() plot w/origin markers"); |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
124 |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
125 %!demo |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
126 %! clf; |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
127 %! [x,y] = meshgrid (1:2:20); |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
128 %! h = quiver (x,y, sin (2*pi*x/10), sin (2*pi*y/10)); |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
129 %! set (h, "marker", "o"); |
6915cc404dba
doc: Clarify quiver/quiver3 documentation when a linestyle is given (bug #52608).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
130 %! title ("quiver() plot w/origin markers and arrowheads"); |
7120 | 131 |
132 %!demo | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
133 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
134 %! x = linspace (0, 3, 80); |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
135 %! y = sin (2*pi*x); |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
136 %! theta = 2*pi*x + pi/2; |
17671 | 137 %! quiver (x, y, sin (theta)/10, cos (theta)/10, 0.4); |
138 %! axis equal tight; | |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
139 %! hold on; plot (x,y,"r"); hold off; |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
140 %! title ("quiver() with scaled arrows"); |
32044
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
141 |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
142 |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
143 %!test <*39552> # Check arrow length, scale factor adjustment, one arrow. |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
144 %! hf = figure ("visible", "off"); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
145 %! hax = gca (); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
146 %! unwind_protect |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
147 %! [x,y] = meshgrid (1:2); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
148 %! u = [0 1; 2 3]; |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
149 %! v = [1 2; 3 4]; |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
150 %! numpts = numel (x); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
151 %! sf = 0.5; |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
152 %! |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
153 %! ## Check single arrow. |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
154 %! h = quiver (hax, x(4), y(4), u(4), v(4), 1); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
155 %! childxdata = get (get (h, "children"), "xdata"); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
156 %! stemchild = find (cellfun (@numel, childxdata) == 3); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
157 %! xendpoint = childxdata{stemchild}(2); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
158 %! assert (xendpoint, x(4) + u(4), eps); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
159 %! |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
160 %! h = quiver (hax, x(4), y(4), u(4), v(4), sf); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
161 %! childxdata = get (get (h, "children"), "xdata"); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
162 %! stemchild = find (cellfun (@numel, childxdata) == 3); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
163 %! xendpoint = childxdata{stemchild}(2); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
164 %! assert (xendpoint, x(4) + sf*u(4), eps); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
165 %! |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
166 %! unwind_protect_cleanup |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
167 %! close (hf); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
168 %! end_unwind_protect |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
169 |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
170 %!test <*39552> # Check arrow length, scale factor adjustment, multiple arrows. |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
171 %! hf = figure ("visible", "off"); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
172 %! hax = gca (); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
173 %! unwind_protect |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
174 %! [x,y] = meshgrid (1:2); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
175 %! u = [0 1; 2 3]; |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
176 %! v = [1 2; 3 4]; |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
177 %! numpts = numel (x); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
178 %! sf = 0.5; |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
179 %! |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
180 %! ## Check multiple arrows. |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
181 %! h = quiver (hax, x, y, u, v, 1); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
182 %! childxdata = get (get (h, "children"), "xdata"); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
183 %! stemchild = find (cellfun (@numel, childxdata) == 3*numpts); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
184 %! xendpoint1 = childxdata{stemchild}(5); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
185 %! xendpoint2 = childxdata{stemchild}(11); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
186 %! assert (xendpoint1, x(2) + (sqrt(2)/10)*u(2), eps); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
187 %! assert (xendpoint2, x(4) + (sqrt(2)/10)*u(4), eps); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
188 %! |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
189 %! h = quiver (hax, x, y, u, v, sf); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
190 %! childxdata = get (get (h, "children"), "xdata"); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
191 %! stemchild = find (cellfun (@numel, childxdata) == 3*numpts); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
192 %! xendpoint1 = childxdata{stemchild}(5); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
193 %! xendpoint2 = childxdata{stemchild}(11); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
194 %! assert (xendpoint1, x(2) + sf*(sqrt(2)/10)*u(2), eps); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
195 %! assert (xendpoint2, x(4) + sf*(sqrt(2)/10)*u(4), eps); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
196 %! |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
197 %! unwind_protect_cleanup |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
198 %! close (hf); |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
199 %! end_unwind_protect |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
200 |
32062
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
201 %!test <*59695> # Check for proper plotting with non-float inputs. |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
202 %! hf = figure ("visible", "off"); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
203 %! hax = gca (); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
204 %! unwind_protect |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
205 %! h = quiver (int32(1), int32(1), int32(1), int32(1), double(0.5)); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
206 %! childxdata = get (get (h, "children"), "xdata"); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
207 %! childydata = get (get (h, "children"), "ydata"); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
208 %! assert (all (strcmp (cellfun (... |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
209 %! 'class', childxdata, 'UniformOutput', false), "double"))); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
210 %! assert (all (strcmp (cellfun (... |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
211 %! 'class', childydata, 'UniformOutput', false), "double"))); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
212 %! assert (childxdata{2}(2) , 1.5, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
213 %! assert (childxdata{3}(2) , 1.5, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
214 %! assert (childydata{2}(2) , 1.5, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
215 %! assert (childydata{3}(2) , 1.5, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
216 %! |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
217 %! h = quiver (0.5, 0.5, 0.5, 0.5, int32(1)); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
218 %! childxdata = get (get (h, "children"), "xdata"); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
219 %! childydata = get (get (h, "children"), "ydata"); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
220 %! assert (all (strcmp (cellfun (... |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
221 %! 'class', childxdata, 'UniformOutput', false), "double"))); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
222 %! assert (all (strcmp (cellfun (... |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
223 %! 'class', childydata, 'UniformOutput', false), "double"))); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
224 %! assert (childxdata{2}(2) , 1, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
225 %! assert (childxdata{3}(2) , 1, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
226 %! assert (childydata{2}(2) , 1, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
227 %! assert (childydata{3}(2) , 1, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
228 %! |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
229 %! h = quiver (false, true, false, true, true); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
230 %! childxdata = get (get (h, "children"), "xdata"); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
231 %! childydata = get (get (h, "children"), "ydata"); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
232 %! assert (all (strcmp (cellfun (... |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
233 %! 'class', childxdata, 'UniformOutput', false), "double"))); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
234 %! assert (all (strcmp (cellfun (... |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
235 %! 'class', childydata, 'UniformOutput', false), "double"))); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
236 %! assert (childxdata{2}(2) , 0, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
237 %! assert (childxdata{3}(2) , 0, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
238 %! assert (childydata{2}(2) , 2, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
239 %! assert (childydata{3}(2) , 2, eps); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
240 %! |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
241 %! unwind_protect_cleanup |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
242 %! close (hf); |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
243 %! end_unwind_protect |
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
244 |
32044
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
245 ## Test input validation |
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
246 %!error <Invalid call> quiver() |
32062
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
247 %!error <Invalid call> quiver(1.1) |
32044
31f7f5359ba2
quiver: Add scale factor and input validation BISTs (bug #39552)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
31706
diff
changeset
|
248 |
32062
ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents:
32044
diff
changeset
|
249 |