Mercurial > hg > octave-nkf
annotate scripts/plot/draw/quiver3.m @ 17671:ddfc1600a311
Overhaul quiver/quiver3 functions.
* scripts/plot/draw/private/__quiver__.m: Scale arrowsize parameter internally
from 0.2 to 1/3 to match Matlab visual results. Assume meshgridded input for
2-D inputs. For vectors, assume a square grid with side length = sqrt (numel
(x)). Use __next_line_color__, rather than assuming 'k', if no colorspec is
given. Ignore second input to listeners with '~'. Set multiple graphic
properties at onec to reduce overhead in calling get/set.
* scripts/plot/draw/quiver.m: Update docstring. Replace 'retval' with 'h' to
match function documentation. Use common unwind_protect sequence with call
to newplot. Add titles to %!demos.
* scripts/plot/draw/quiver3.m: Update docstring. Replace 'retval' with 'h' to
match function documentation. Use common unwind_protect sequence with call
to newplot. Add titles to %!demos.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 17 Oct 2013 08:58:50 -0700 |
parents | ea9df126c9a5 |
children | d63878346099 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14092
diff
changeset
|
1 ## Copyright (C) 2007-2012 David Bateman |
7189 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
9040
diff
changeset
|
20 ## @deftypefn {Function File} {} quiver3 (@var{u}, @var{v}, @var{w}) |
7189 | 21 ## @deftypefnx {Function File} {} quiver3 (@var{x}, @var{y}, @var{z}, @var{u}, @var{v}, @var{w}) |
22 ## @deftypefnx {Function File} {} quiver3 (@dots{}, @var{s}) | |
23 ## @deftypefnx {Function File} {} quiver3 (@dots{}, @var{style}) | |
14359
7277fe922e99
doc: Use Octave preference for double quote in docstrings in scripts/
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
24 ## @deftypefnx {Function File} {} quiver3 (@dots{}, "filled") |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
25 ## @deftypefnx {Function File} {} quiver3 (@var{hax}, @dots{}) |
7189 | 26 ## @deftypefnx {Function File} {@var{h} =} quiver3 (@dots{}) |
27 ## | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
28 ## Plot the (@var{u}, @var{v}, @var{w}) components of a vector field in |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
29 ## an (@var{x}, @var{y}, @var{z}) meshgrid. If the grid is uniform, you |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
30 ## can specify @var{x}, @var{y}, and @var{z} as vectors. |
7189 | 31 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
32 ## If @var{x}, @var{y}, and @var{z} are undefined they are assumed to be |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
33 ## @code{(1:@var{m}, 1:@var{n}, 1:@var{p})} where @code{[@var{m}, @var{n}] = |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
34 ## size (@var{u})} and @code{@var{p} = max (size (@var{w}))}. |
7189 | 35 ## |
36 ## The variable @var{s} is a scalar defining a scaling factor to use for | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
37 ## the arrows of the field relative to the mesh spacing. A value of 0 |
17671 | 38 ## disables all scaling. The default value is 0.9. |
7189 | 39 ## |
40 ## The style to use for the plot can be defined with a line style @var{style} | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
41 ## of the same format as the @code{plot} command. |
7189 | 42 ## If a marker is specified then markers at the grid points of the vectors are |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17211
diff
changeset
|
43 ## drawn rather than arrows. If the argument @qcode{"filled"} is given then the |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
44 ## markers are filled. |
7189 | 45 ## |
17161
52931d71400f
doc: Document that first argument can be an axes handle for several plot functions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
46 ## If the first argument @var{hax} is an axes handle, then plot into this axis, |
52931d71400f
doc: Document that first argument can be an axes handle for several plot functions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
47 ## 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
|
48 ## |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
49 ## 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
|
50 ## 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
|
51 ## and marker), and allows them to be changed together. |
7189 | 52 ## |
53 ## @example | |
54 ## @group | |
55 ## [x, y, z] = peaks (25); | |
56 ## surf (x, y, z); | |
57 ## hold on; | |
58 ## [u, v, w] = surfnorm (x, y, z / 10); | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
59 ## h = quiver3 (x, y, z, u, v, w); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
60 ## set (h, "maxheadsize", 0.33); |
7189 | 61 ## @end group |
62 ## @end example | |
63 ## | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
64 ## @seealso{quiver, compass, feather, plot} |
7189 | 65 ## @end deftypefn |
66 | |
17671 | 67 function h = quiver3 (varargin) |
7189 | 68 |
17070
d465f9970c02
quiver.m, quiver3.m: Upgrade to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
69 [hax, varargin, nargin] = __plt_get_axis_arg__ ("quiver3", varargin{:}); |
7215 | 70 |
7189 | 71 if (nargin < 2) |
72 print_usage (); | |
17671 | 73 endif |
74 | |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17161
diff
changeset
|
75 oldfig = []; |
17301
68bcac3c043a
Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
76 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
|
77 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
|
78 endif |
17671 | 79 unwind_protect |
80 hax = newplot (hax); | |
81 htmp = __quiver__ (hax, true, varargin{:}); | |
17070
d465f9970c02
quiver.m, quiver3.m: Upgrade to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
82 |
17671 | 83 if (! ishold (hax)) |
84 set (hax, "view", [-37.5, 30], "box", "off", | |
85 "xgrid", "on", "ygrid", "on", "zgrid", "on"); | |
86 endif | |
87 unwind_protect_cleanup | |
88 if (! isempty (oldfig)) | |
89 set (0, "currentfigure", oldfig); | |
90 endif | |
91 end_unwind_protect | |
7189 | 92 |
93 if (nargout > 0) | |
17671 | 94 h = htmp; |
7189 | 95 endif |
96 | |
97 endfunction | |
98 | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
99 |
7189 | 100 %!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
|
101 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14245
diff
changeset
|
102 %! colormap ('default'); |
7245 | 103 %! [x, y, z] = peaks (25); |
104 %! surf (x, y, z); | |
105 %! hold on; | |
106 %! [u, v, w] = surfnorm (x, y, z / 10); | |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7245
diff
changeset
|
107 %! h = quiver3 (x, y, z, u, v, w); |
17671 | 108 %! set (h, 'maxheadsize', 0.25); |
8253
873ea2c72f16
quiver3.m: turn hold off after demo
John W. Eaton <jwe@octave.org>
parents:
8056
diff
changeset
|
109 %! hold off; |
17671 | 110 %! title ('quiver3 of surface normals to peaks() function'); |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8253
diff
changeset
|
111 |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8253
diff
changeset
|
112 %!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
|
113 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14245
diff
changeset
|
114 %! colormap ('default'); |
14092
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
115 %! [x, y, z] = peaks (25); |
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
116 %! surf (x, y, z); |
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
117 %! hold on; |
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
118 %! [u, v, w] = surfnorm (x, y, z / 10); |
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
119 %! h = quiver3 (x, y, z, u, v, w); |
17671 | 120 %! set (h, 'maxheadsize', 0.25); |
14092
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
121 %! hold off; |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
122 %! shading interp; |
17671 | 123 %! title ({'quiver3 of surface normals to peaks() function'; ... |
124 %! 'shading "interp"'}); | |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8253
diff
changeset
|
125 |