1 ## Copyright (C) 2007-2012 David Bateman
3 ## This file is part of Octave.
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.
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.
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/>.
20 ## @c List other forms of function in documentation index
24 ## @deftypefn {Function File} {@var{xl} =} xlim ()
25 ## @deftypefnx {Function File} {} xlim (@var{xl})
26 ## @deftypefnx {Function File} {@var{m} =} xlim ('mode')
27 ## @deftypefnx {Function File} {} xlim (@var{m})
28 ## @deftypefnx {Function File} {} xlim (@var{h}, @dots{})
29 ## Get or set the limits of the x-axis of the current plot. Called without
30 ## arguments @code{xlim} returns the x-axis limits of the current plot.
31 ## If passed a two element vector @var{xl}, the limits of the x-axis are set
34 ## The current mode for calculation of the x-axis can be returned with a
35 ## call @code{xlim ('mode')}, and can be either 'auto' or 'manual'. The
36 ## current plotting mode can be set by passing either 'auto' or 'manual'
39 ## If passed a handle as the first argument, then operate on this handle
40 ## rather than the current axes handle.
41 ## @seealso{ylim, zlim, set, get, gca}
44 function retval = xlim (varargin)
45 ret = __axes_limits__ ("xlim", varargin{:});
56 %! title ("xlim is [0.2, 0.8]");
57 %! assert (xlim (), [0.2, 0.8]);
63 %! title ("xlim is auto");
64 %! assert (xlim ("mode"), "auto");
68 %! plot3 ([0,1], [0,1], [0,1]);
70 %! title ("xlim is [0.2, 0.8]");
71 %! assert (xlim (), [0.2, 0.8]);
75 %! plot3 ([0,1], [0,1], [0,1]);
77 %! title ("xlim is auto");
78 %! assert (xlim ("mode"), "auto");
82 %! hf = figure ("visible", "off");
84 %! plot3 ([0,1], [0,1], [0,1]);
86 %! assert (get (gca, "xlim"), [0, 1.1], eps);
87 %! assert (xlim ("mode"), "manual");
88 %! unwind_protect_cleanup
93 %! hf = figure ("visible", "off");
95 %! h = plot3 ([0,1.1], [0,1], [0, 1]);
96 %! assert (get (gca, "xlim"), [0, 1.4], eps);
97 %! assert (xlim ("mode"), "auto");
98 %! unwind_protect_cleanup
100 %! end_unwind_protect