Mercurial > hg > octave-nkf
annotate scripts/plot/draw/quiver3.m @ 20407:2283dd03bf50
ginput.m: Don't hang if window is close while fcn active (bug #44897).
* ginput.m: Change closerequestfcn for figure to point to ginput_closerequestfcn.
* ginput.m (ginput_closerequestfcn): New callback routine. Stops collecting
data for ginput. Calls original closerequestfcn to shutdown window.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 15 May 2015 16:51:57 -0700 |
parents | aa36fb998a4d |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
1 ## Copyright (C) 2007-2015 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 ## | |
20383
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
28 ## Plot a 3-D vector field with arrows. |
20391
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20383
diff
changeset
|
29 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
30 ## Plot the (@var{u}, @var{v}, @var{w}) components of a vector field in |
20383
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
31 ## an (@var{x}, @var{y}, @var{z}) meshgrid. If the grid is uniform then |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
32 ## @var{x}, @var{y}, and @var{z} can be specified as vectors. |
7189 | 33 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
34 ## 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
|
35 ## @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
|
36 ## size (@var{u})} and @code{@var{p} = max (size (@var{w}))}. |
7189 | 37 ## |
38 ## 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
|
39 ## the arrows of the field relative to the mesh spacing. A value of 0 |
17671 | 40 ## disables all scaling. The default value is 0.9. |
7189 | 41 ## |
42 ## 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
|
43 ## of the same format as the @code{plot} command. |
7189 | 44 ## 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
|
45 ## 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
|
46 ## markers are filled. |
7189 | 47 ## |
17161
52931d71400f
doc: Document that first argument can be an axes handle for several plot functions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
48 ## 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
|
49 ## 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
|
50 ## |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
51 ## 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
|
52 ## 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
|
53 ## and marker), and allows them to be changed together. |
7189 | 54 ## |
55 ## @example | |
56 ## @group | |
57 ## [x, y, z] = peaks (25); | |
58 ## surf (x, y, z); | |
59 ## hold on; | |
60 ## [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
|
61 ## 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
|
62 ## set (h, "maxheadsize", 0.33); |
7189 | 63 ## @end group |
64 ## @end example | |
65 ## | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17070
diff
changeset
|
66 ## @seealso{quiver, compass, feather, plot} |
7189 | 67 ## @end deftypefn |
68 | |
17671 | 69 function h = quiver3 (varargin) |
7189 | 70 |
17070
d465f9970c02
quiver.m, quiver3.m: Upgrade to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
71 [hax, varargin, nargin] = __plt_get_axis_arg__ ("quiver3", varargin{:}); |
7215 | 72 |
7189 | 73 if (nargin < 2) |
74 print_usage (); | |
17671 | 75 endif |
76 | |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17161
diff
changeset
|
77 oldfig = []; |
17301
68bcac3c043a
Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
78 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
|
79 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
|
80 endif |
17671 | 81 unwind_protect |
82 hax = newplot (hax); | |
83 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
|
84 |
17671 | 85 if (! ishold (hax)) |
86 set (hax, "view", [-37.5, 30], "box", "off", | |
87 "xgrid", "on", "ygrid", "on", "zgrid", "on"); | |
88 endif | |
89 unwind_protect_cleanup | |
90 if (! isempty (oldfig)) | |
91 set (0, "currentfigure", oldfig); | |
92 endif | |
93 end_unwind_protect | |
7189 | 94 |
95 if (nargout > 0) | |
17671 | 96 h = htmp; |
7189 | 97 endif |
98 | |
99 endfunction | |
100 | |
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 |
7189 | 102 %!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
|
103 %! 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
|
104 %! colormap ('default'); |
7245 | 105 %! [x, y, z] = peaks (25); |
106 %! surf (x, y, z); | |
107 %! hold on; | |
108 %! [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
|
109 %! h = quiver3 (x, y, z, u, v, w); |
17671 | 110 %! set (h, 'maxheadsize', 0.25); |
8253
873ea2c72f16
quiver3.m: turn hold off after demo
John W. Eaton <jwe@octave.org>
parents:
8056
diff
changeset
|
111 %! hold off; |
17671 | 112 %! 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
|
113 |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8253
diff
changeset
|
114 %!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
|
115 %! 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
|
116 %! colormap ('default'); |
14092
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
117 %! [x, y, z] = peaks (25); |
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
118 %! surf (x, y, z); |
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
119 %! hold on; |
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
120 %! [u, v, w] = surfnorm (x, y, z / 10); |
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
121 %! h = quiver3 (x, y, z, u, v, w); |
17671 | 122 %! set (h, 'maxheadsize', 0.25); |
14092
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
123 %! 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
|
124 %! shading interp; |
17671 | 125 %! title ({'quiver3 of surface normals to peaks() function'; ... |
126 %! '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
|
127 |