Mercurial > hg > octave-lyh
annotate scripts/plot/xlim.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 | bc924baa2c4e |
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 | 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 -*- | |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14359
diff
changeset
|
20 ## @deftypefn {Function File} {@var{xlimits} =} xlim () |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14359
diff
changeset
|
21 ## @deftypefnx {Function File} {@var{xmode} =} xlim ("mode") |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14359
diff
changeset
|
22 ## @deftypefnx {Function File} {} xlim ([@var{x_lo} @var{x_hi}]) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14359
diff
changeset
|
23 ## @deftypefnx {Function File} {} xlim ("auto") |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14359
diff
changeset
|
24 ## @deftypefnx {Function File} {} xlim ("manual") |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14359
diff
changeset
|
25 ## @deftypefnx {Function File} {} xlim (@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 x-axis of the current plot. |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
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{xlim} returns the x-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 x-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{x_lo} @var{x_hi}], the limits of the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14359
diff
changeset
|
33 ## x-axis are set to these values. |
7050 | 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. |
7050 | 37 ## |
17126
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{ylim, zlim, axis, set, get, gca} |
7050 | 41 ## @end deftypefn |
42 | |
43 function retval = xlim (varargin) | |
7208 | 44 ret = __axes_limits__ ("xlim", varargin{:}); |
7050 | 45 |
46 if (! isempty (ret)) | |
47 retval = ret; | |
48 endif | |
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:
14171
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:
14171
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 %! xlim ([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 ('xlim 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 (xlim (), [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:
14171
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 %! xlim ('auto'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
63 %! title ('xlim is auto'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
64 %! assert (xlim ('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:
14171
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 %! xlim ([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 ('xlim 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 (xlim (), [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:
14171
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 %! xlim ('auto'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
77 %! title ('xlim is auto'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
78 %! assert (xlim ('mode'), 'auto'); |
13096 | 79 |
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 | 83 %! plot3 ([0,1], [0,1], [0,1]); |
84 %! xlim ([0, 1.1]); | |
85 %! assert (get (gca, "xlim"), [0, 1.1], eps); | |
86 %! assert (xlim ("mode"), "manual"); | |
87 %! unwind_protect_cleanup | |
88 %! close (hf); | |
89 %! end_unwind_protect | |
90 | |
91 %!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
|
92 %! 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
|
93 %! unwind_protect |
13096 | 94 %! h = plot3 ([0,1.1], [0,1], [0, 1]); |
95 %! assert (get (gca, "xlim"), [0, 1.4], eps); | |
96 %! assert (xlim ("mode"), "auto"); | |
97 %! unwind_protect_cleanup | |
98 %! close (hf); | |
99 %! end_unwind_protect | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
100 |