2303
|
1 ### Copyright (C) 1996 John W. Eaton |
|
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 |
2311
|
20 ## usage: axis () |
|
21 ## axis ([xmin, xmax]) |
|
22 ## axis ([xmin, xmax, ymin, ymax]) |
|
23 ## axis ([xmin, xmax, ymin, ymax, zmin, zmax]) |
|
24 ## |
|
25 ## Sets the axis limits. |
|
26 ## |
|
27 ## With no arguments, turns autoscaling on. |
|
28 ## |
|
29 ## If your plot is already drawn, then you need to REPLOT before |
|
30 ## the new axis limits will take effect. |
590
|
31 |
2311
|
32 function curr_axis = axis (ax) |
590
|
33 |
2303
|
34 ## This may not be correct if someone has used the gnuplot interface |
|
35 ## directly... |
1610
|
36 |
|
37 global __current_axis__; |
|
38 |
|
39 if (! exist ("__current_axis__")) |
|
40 __current_axis__ = [-10, 10, -10, 10]; |
|
41 endif |
|
42 |
595
|
43 if (nargin > 1) |
904
|
44 usage ("axis ([xmin, xmax, ymin, ymax, zmin, zmax])"); |
590
|
45 endif |
|
46 |
595
|
47 if (nargin == 0) |
|
48 set autoscale; |
1610
|
49 curr_axis = __current_axis__; |
595
|
50 elseif (is_vector (ax)) |
590
|
51 |
|
52 len = length (ax); |
|
53 |
|
54 if (len != 2 && len != 4 && len != 6) |
|
55 error ("axis: expecting vector with 2, 4, or 6 elements"); |
|
56 endif |
|
57 |
1610
|
58 __current_axis__ = reshape (ax, 1, len); |
|
59 |
590
|
60 if (len > 1) |
594
|
61 eval (sprintf ("set xrange [%g:%g];", ax (1), ax (2))); |
590
|
62 endif |
|
63 |
|
64 if (len > 3) |
594
|
65 eval (sprintf ("set yrange [%g:%g];", ax (3), ax (4))); |
590
|
66 endif |
|
67 |
|
68 if (len > 5) |
594
|
69 eval (sprintf ("set zrange [%g:%g];", ax (5), ax (6))); |
590
|
70 endif |
|
71 |
|
72 else |
595
|
73 error ("axis: expecting no args, or a vector with 2, 4, or 6 elements"); |
590
|
74 endif |
|
75 |
|
76 endfunction |