annotate scripts/plot/ylim.m @ 17130:26589abbc78d

Don't pass axis handle unnecessarily from high level to low level plot functions. * scripts/plot/comet.m, scripts/plot/comet3.m, scripts/plot/compass.m, scripts/plot/contour.m, scripts/plot/contourf.m, scripts/plot/cylinder.m, scripts/plot/ellipsoid.m, scripts/plot/errorbar.m, scripts/plot/feather.m, scripts/plot/mesh.m, scripts/plot/meshc.m, scripts/plot/meshz.m, scripts/plot/pcolor.m, scripts/plot/plot3.m, scripts/plot/rectangle.m, scripts/plot/rose.m, scripts/plot/scatter3.m, scripts/plot/semilogxerr.m, scripts/plot/semilogy.m, scripts/plot/semilogyerr.m, scripts/plot/slice.m, scripts/plot/sphere.m, scripts/plot/stairs.m, scripts/plot/surf.m, scripts/plot/surfc.m, scripts/plot/surfnorm.m, scripts/plot/trimesh.m, scripts/plot/trisurf.m: Don't pass hax to lower level functions after newplot() has been called.
author Rik <rik@octave.org>
date Wed, 31 Jul 2013 18:42:17 -0700
parents eaab03308c0b
children bc924baa2c4e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
1 ## Copyright (C) 2007-2012 David Bateman
7050
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
2 ##
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
3 ## This file is part of Octave.
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
4 ##
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
8 ## your option) any later version.
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
9 ##
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
13 ## General Public License for more details.
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
14 ##
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
18
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
19 ## -*- texinfo -*-
17126
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
20 ## @deftypefn {Function File} {@var{ylimits} =} ylim ()
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
21 ## @deftypefnx {Function File} {@var{xmode} =} ylim ("mode")
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
22 ## @deftypefnx {Function File} {} ylim ([@var{y_lo} @var{y_hi}])
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
23 ## @deftypefnx {Function File} {} ylim ("auto")
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
24 ## @deftypefnx {Function File} {} ylim ("manual")
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
25 ## @deftypefnx {Function File} {} ylim (@var{hax}, @dots{})
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
26 ## Query or set the limits of the y-axis of the current plot.
7050
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
27 ##
17126
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
28 ## Called without arguments @code{ylim} returns the y-axis limits of the
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
29 ## current plot. With the input query "mode", return the current y-limit
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
30 ## calculation mode which is either "auto" or "manual".
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
31 ##
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
32 ## If passed a 2-element vector [@var{y_lo} @var{y_hi}], the limits of the
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
33 ## y-axis are set to these values.
7050
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
34 ##
17126
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
35 ## The current plotting mode can be set by passing either "auto" or "manual" as
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
36 ## the argument.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
37 ##
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
38 ## If the first argument @var{hax} is an axes handle, then operate on
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
39 ## this axis rather than the current axes returned by @code{gca}.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14359
diff changeset
40 ## @seealso{xlim, zlim, axis, set, get, gca}
7050
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
41 ## @end deftypefn
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
42
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
43 function retval = ylim (varargin)
7208
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7050
diff changeset
44 ret = __axes_limits__ ("ylim", varargin{:});
7050
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
45
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
46 if (! isempty (ret))
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
47 retval = ret;
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
48 endif
bd56a0609c4f [project @ 2007-10-23 12:02:17 by dbateman]
dbateman
parents:
diff changeset
49 endfunction
13083
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
50
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
51
13083
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
52 %!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
53 %! clf;
13083
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
54 %! line ();
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
55 %! ylim ([0.2, 0.8]);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
56 %! title ('ylim is [0.2, 0.8]');
13083
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
57 %! assert (ylim (), [0.2, 0.8]);
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
58
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
59 %!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
60 %! clf;
13083
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
61 %! line ();
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
62 %! ylim ('auto');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
63 %! title ('ylim is auto');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
64 %! assert (ylim ('mode'), 'auto');
13083
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
65
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
66 %!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
67 %! clf;
13083
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
68 %! plot3 ([0,1], [0,1], [0,1]);
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
69 %! ylim ([0.2, 0.8]);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
70 %! title ('ylim is [0.2, 0.8]');
13083
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
71 %! assert (ylim (), [0.2, 0.8]);
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
72
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
73 %!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
74 %! clf;
13083
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
75 %! plot3 ([0,1], [0,1], [0,1]);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
76 %! ylim ('auto');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
77 %! title ('ylim is auto');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
78 %! assert (ylim ('mode'), 'auto');
13083
0e231bbd78bc codesprint: demos for xlim, ylim, and zlim
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
79
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
80 %!test
13124
2ea1658ad049 Don't use explicit figure number for tests to avoid interference with any figures opened by user.
Kai Habel <kai.habel@gmx.de>
parents: 13096
diff changeset
81 %! hf = figure ("visible", "off");
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13124
diff changeset
82 %! unwind_protect
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
83 %! limy = [0, 1.1];
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
84 %! plot3 ([0,1], [0,1], [0,1]);
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
85 %! ylim (limy);
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
86 %! assert (get (gca, "ylim"), limy, eps);
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
87 %! assert (ylim ("mode"), "manual");
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
88 %! unwind_protect_cleanup
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
89 %! close (hf);
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
90 %! end_unwind_protect
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
91
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
92 %!test
13124
2ea1658ad049 Don't use explicit figure number for tests to avoid interference with any figures opened by user.
Kai Habel <kai.habel@gmx.de>
parents: 13096
diff changeset
93 %! hf = figure ("visible", "off");
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13124
diff changeset
94 %! unwind_protect
13096
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
95 %! plot3 ([0,1], [0,1.1], [0, 1]);
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
96 %! assert (get (gca, "ylim"), [0, 1.4], eps);
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
97 %! assert (ylim ("mode"), "auto");
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
98 %! unwind_protect_cleanup
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
99 %! close (hf);
5553412c6614 Tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 13083
diff changeset
100 %! end_unwind_protect
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