Mercurial > hg > octave-lyh
annotate scripts/plot/contour3.m @ 17129:b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
* scripts/geometry/voronoi.m, scripts/image/imagesc.m,
scripts/plot/__plt_get_axis_arg__.m, scripts/plot/axes.m, scripts/plot/cla.m,
scripts/plot/colorbar.m, scripts/plot/hold.m, scripts/plot/legend.m,
scripts/plot/plotmatrix.m, scripts/plot/plotyy.m,
scripts/plot/private/__errplot__.m, scripts/plot/private/__plt__.m,
scripts/plot/view.m: Use new isaxes function to simplify code.
* scripts/plot/shading.m: Use Octave convention for spacing of parentheses.
* scripts/plot/zlabel.m: Correct %!test incorrectly calling plot3 with figure
handle.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 31 Jul 2013 16:27:49 -0700 |
parents | eaab03308c0b |
children | df4c4b7708a4 |
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 |
7175 | 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} {} contour3 (@var{z}) |
7317 | 21 ## @deftypefnx {Function File} {} contour3 (@var{z}, @var{vn}) |
22 ## @deftypefnx {Function File} {} contour3 (@var{x}, @var{y}, @var{z}) | |
23 ## @deftypefnx {Function File} {} contour3 (@var{x}, @var{y}, @var{z}, @var{vn}) | |
24 ## @deftypefnx {Function File} {} contour3 (@dots{}, @var{style}) | |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
25 ## @deftypefnx {Function File} {} contour3 (@var{hax}, @dots{}) |
7175 | 26 ## @deftypefnx {Function File} {[@var{c}, @var{h}] =} contour3 (@dots{}) |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
27 ## Create a 3-D contour plot. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
28 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
29 ## @code{contour3} plots level curves (contour lines) of the matrix @var{z} |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
30 ## at a Z level corresponding to each contour. This is in contrast to |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
31 ## @code{contour} which plots all of the contour lines at the same Z level |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
32 ## and produces a 2-D plot. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
33 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
34 ## The level curves are taken from the contour matrix @var{c} computed by |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
35 ## @code{contourc} for the same arguments; see the latter for their |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
36 ## interpretation. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
37 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
38 ## The appearance of contour lines can be defined with a line style @var{style} |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
39 ## in the same manner as @code{plot}. Only line style and color are used; |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
40 ## Any markers defined by @var{style} are ignored. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
41 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
42 ## If the first argument @var{hax} is an axes handle, then plot into this axis, |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
43 ## rather than the current axes returned by @code{gca}. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
44 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
45 ## The optional output @var{c} are the contour levels in @code{contourc} format. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
46 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
47 ## The optional return value @var{h} is a graphics handle to the hggroup |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
48 ## comprising the contour lines. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
49 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
50 ## Example: |
7175 | 51 ## |
52 ## @example | |
53 ## @group | |
54 ## contour3 (peaks (19)); | |
16814
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
14335
diff
changeset
|
55 ## hold on; |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
56 ## surface (peaks (19), "facecolor", "none", "EdgeColor", "black"); |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
57 ## colormap hot; |
7175 | 58 ## @end group |
59 ## @end example | |
60 ## | |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
61 ## @seealso{contour, contourc, contourf, clabel, meshc, surfc, caxis, colormap, plot} |
7175 | 62 ## @end deftypefn |
63 | |
64 function [c, h] = contour3 (varargin) | |
65 | |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
66 [hax, varargin, nargin] = __plt_get_axis_arg__ ("contour3", varargin{:}); |
7216 | 67 |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
68 oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); |
7215 | 69 unwind_protect |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
70 hax = newplot (hax); |
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
71 |
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
72 [ctmp, htmp] = __contour__ (hax, "auto", varargin{:}); |
7215 | 73 unwind_protect_cleanup |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
74 if (! isempty (oldfig)) |
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
75 set (0, "currentfigure", oldfig); |
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
76 endif |
7215 | 77 end_unwind_protect |
7175 | 78 |
79 if (! ishold ()) | |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
80 set (hax, "view", [-37.5, 30], |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
81 "xgrid", "on", "ygrid", "on", "zgrid", "on"); |
7175 | 82 endif |
83 | |
84 if (nargout > 0) | |
85 c = ctmp; | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
7317
diff
changeset
|
86 h = htmp; |
7175 | 87 endif |
88 | |
89 endfunction | |
7245 | 90 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
91 |
7245 | 92 %!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
|
93 %! clf; |
7245 | 94 %! contour3 (peaks (19)); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
95 %! hold on; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
96 %! surface (peaks (19), 'facecolor', 'none', 'edgecolor', 'black'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
97 %! colormap (hot (64)); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
98 %! axis tight; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
99 %! zlim auto; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
100 %! box off; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
101 %! hold off; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
102 |