2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
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 2, or (at your option) |
|
8 ## 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, write to the Free |
|
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|
18 ## 02111-1307, USA. |
590
|
19 |
3368
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} axis (@var{limits}) |
|
22 ## Sets the axis limits for plots. |
|
23 ## |
|
24 ## The argument @var{limits} should be a 2, 4, or 6 element vector. The |
|
25 ## first and second elements specify the lower and upper limits for the x |
|
26 ## axis. The third and fourth specify the limits for the y axis, and the |
|
27 ## fifth and sixth specify the limits for the z axis. |
|
28 ## |
|
29 ## With no arguments, @code{axis} turns autoscaling on. |
|
30 ## |
|
31 ## If your plot is already drawn, then you need to use @code{replot} before |
|
32 ## the new axis limits will take effect. You can get this to happen |
|
33 ## automatically by setting the built-in variable @code{automatic_replot} |
|
34 ## to a nonzero value. |
|
35 ## @end deftypefn |
590
|
36 |
2314
|
37 ## Author: jwe |
|
38 |
2311
|
39 function curr_axis = axis (ax) |
590
|
40 |
2303
|
41 ## This may not be correct if someone has used the gnuplot interface |
|
42 ## directly... |
1610
|
43 |
3106
|
44 global __current_axis__ = [-10, 10, -10, 10]; |
1610
|
45 |
595
|
46 if (nargin > 1) |
904
|
47 usage ("axis ([xmin, xmax, ymin, ymax, zmin, zmax])"); |
590
|
48 endif |
|
49 |
595
|
50 if (nargin == 0) |
2520
|
51 gset autoscale; |
1610
|
52 curr_axis = __current_axis__; |
595
|
53 elseif (is_vector (ax)) |
590
|
54 |
|
55 len = length (ax); |
|
56 |
|
57 if (len != 2 && len != 4 && len != 6) |
|
58 error ("axis: expecting vector with 2, 4, or 6 elements"); |
|
59 endif |
|
60 |
1610
|
61 __current_axis__ = reshape (ax, 1, len); |
|
62 |
590
|
63 if (len > 1) |
2520
|
64 eval (sprintf ("gset xrange [%g:%g];", ax (1), ax (2))); |
590
|
65 endif |
|
66 |
|
67 if (len > 3) |
2520
|
68 eval (sprintf ("gset yrange [%g:%g];", ax (3), ax (4))); |
590
|
69 endif |
|
70 |
|
71 if (len > 5) |
2520
|
72 eval (sprintf ("gset zrange [%g:%g];", ax (5), ax (6))); |
590
|
73 endif |
|
74 |
|
75 else |
595
|
76 error ("axis: expecting no args, or a vector with 2, 4, or 6 elements"); |
590
|
77 endif |
|
78 |
|
79 endfunction |