1887
|
1 # Copyright (C) 1996 John W. Eaton |
590
|
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 the |
|
7 # Free Software Foundation; either version 2, or (at your option) any |
|
8 # later version. |
|
9 # |
|
10 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 # 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 |
1315
|
17 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
590
|
18 |
1610
|
19 function curr_axis = axis (ax) |
590
|
20 |
595
|
21 # usage: axis () |
|
22 # axis ([xmin, xmax]) |
590
|
23 # axis ([xmin, xmax, ymin, ymax]) |
|
24 # axis ([xmin, xmax, ymin, ymax, zmin, zmax]) |
|
25 # |
|
26 # Sets the axis limits. |
|
27 # |
595
|
28 # With no arguments, turns autoscaling on. |
|
29 # |
590
|
30 # If your plot is already drawn, then you need to REPLOT before |
|
31 # the new axis limits will take effect. |
|
32 |
1610
|
33 # This may not be correct if someone has used the gnuplot interface |
|
34 # directly... |
|
35 |
|
36 global __current_axis__; |
|
37 |
|
38 if (! exist ("__current_axis__")) |
|
39 __current_axis__ = [-10, 10, -10, 10]; |
|
40 endif |
|
41 |
595
|
42 if (nargin > 1) |
904
|
43 usage ("axis ([xmin, xmax, ymin, ymax, zmin, zmax])"); |
590
|
44 endif |
|
45 |
595
|
46 if (nargin == 0) |
|
47 set autoscale; |
1610
|
48 curr_axis = __current_axis__; |
595
|
49 elseif (is_vector (ax)) |
590
|
50 |
|
51 len = length (ax); |
|
52 |
|
53 if (len != 2 && len != 4 && len != 6) |
|
54 error ("axis: expecting vector with 2, 4, or 6 elements"); |
|
55 endif |
|
56 |
1610
|
57 __current_axis__ = reshape (ax, 1, len); |
|
58 |
590
|
59 if (len > 1) |
594
|
60 eval (sprintf ("set xrange [%g:%g];", ax (1), ax (2))); |
590
|
61 endif |
|
62 |
|
63 if (len > 3) |
594
|
64 eval (sprintf ("set yrange [%g:%g];", ax (3), ax (4))); |
590
|
65 endif |
|
66 |
|
67 if (len > 5) |
594
|
68 eval (sprintf ("set zrange [%g:%g];", ax (5), ax (6))); |
590
|
69 endif |
|
70 |
|
71 else |
595
|
72 error ("axis: expecting no args, or a vector with 2, 4, or 6 elements"); |
590
|
73 endif |
|
74 |
|
75 endfunction |