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