annotate scripts/plot/draw/quiver3.m @ 22367:459545bc9019

Use ishold () rather than ishold (hax) for performance. * area.m, colorbar.m, contour.m, contourf.m, loglog.m, loglogerr.m, polar.m, __bar__.m, quiver3.m, scatter3.m, semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m, surf.m, surfl.m: Use ishold () rather than ishold (hax) for performance.
author Rik <rik@octave.org>
date Tue, 23 Aug 2016 15:34:19 -0700
parents e6df1ddfc3cf
children 3a2b891d0b33 e9a0469dedd9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22302
diff changeset
1 ## Copyright (C) 2007-2016 David Bateman
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
2 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
3 ## This file is part of Octave.
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
4 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
8 ## your option) any later version.
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
9 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
13 ## General Public License for more details.
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
14 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
18
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20181
diff changeset
20 ## @deftypefn {} {} quiver3 (@var{u}, @var{v}, @var{w})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20181
diff changeset
21 ## @deftypefnx {} {} quiver3 (@var{x}, @var{y}, @var{z}, @var{u}, @var{v}, @var{w})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20181
diff changeset
22 ## @deftypefnx {} {} quiver3 (@dots{}, @var{s})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20181
diff changeset
23 ## @deftypefnx {} {} quiver3 (@dots{}, @var{style})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20181
diff changeset
24 ## @deftypefnx {} {} quiver3 (@dots{}, "filled")
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20181
diff changeset
25 ## @deftypefnx {} {} quiver3 (@var{hax}, @dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20181
diff changeset
26 ## @deftypefnx {} {@var{h} =} quiver3 (@dots{})
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
27 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
28 ## Plot a 3-D vector field with arrows.
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20173
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
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
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: 19697
diff changeset
32 ## @var{x}, @var{y}, and @var{z} can be specified as vectors.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
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
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
37 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
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
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
40 ## disables all scaling. The default value is 0.9.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
41 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
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
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
44 ## If a marker is specified then markers at the grid points of the vectors are
21546
f7f97d7e9294 doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 20852
diff changeset
45 ## drawn rather than arrows. If the argument @qcode{"filled"} is given then
f7f97d7e9294 doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 20852
diff changeset
46 ## the markers are filled.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
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
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
54 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
55 ## @example
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
56 ## @group
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
57 ## [x, y, z] = peaks (25);
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
58 ## surf (x, y, z);
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
59 ## hold on;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
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
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
63 ## @end group
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
64 ## @end example
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
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
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
67 ## @end deftypefn
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
68
17671
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
69 function h = quiver3 (varargin)
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
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
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
72
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
73 if (nargin < 2)
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
74 print_usage ();
17671
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
75 endif
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
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
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
81 unwind_protect
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
82 hax = newplot (hax);
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
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
22367
459545bc9019 Use ishold () rather than ishold (hax) for performance.
Rik <rik@octave.org>
parents: 22351
diff changeset
85 if (! ishold ())
22351
e6df1ddfc3cf Change DefaultAxesBox property to "off".
Rik <rik@octave.org>
parents: 22323
diff changeset
86 set (hax, "view", [-37.5, 30],
17671
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
87 "xgrid", "on", "ygrid", "on", "zgrid", "on");
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
88 endif
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
89 unwind_protect_cleanup
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
90 if (! isempty (oldfig))
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
91 set (0, "currentfigure", oldfig);
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
92 endif
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
93 end_unwind_protect
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
94
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
95 if (nargout > 0)
17671
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
96 h = htmp;
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
97 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
98
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
99 endfunction
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
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
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
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;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21546
diff changeset
104 %! colormap ("default");
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7215
diff changeset
105 %! [x, y, z] = peaks (25);
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7215
diff changeset
106 %! surf (x, y, z);
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7215
diff changeset
107 %! hold on;
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7215
diff changeset
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);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21546
diff changeset
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;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21546
diff changeset
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;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21546
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);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21546
diff changeset
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;
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 21546
diff changeset
125 %! title ({"quiver3 of surface normals to peaks() function"; ...
17671
ddfc1600a311 Overhaul quiver/quiver3 functions.
Rik <rik@octave.org>
parents: 17670
diff changeset
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