annotate scripts/plot/axis.m @ 1610:26a096727e89

[project @ 1995-11-03 05:57:27 by jwe]
author jwe
date Fri, 03 Nov 1995 05:57:27 +0000
parents 611d403c7f3d
children 5d29638dd524
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1014
3f257ab07921 [project @ 1995-01-04 19:06:56 by jwe]
jwe
parents: 904
diff changeset
1 # Copyright (C) 1993, 1994, 1995 John W. Eaton
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
2 #
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
3 # This file is part of Octave.
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
4 #
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
5 # Octave is free software; you can redistribute it and/or modify it
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
6 # under the terms of the GNU General Public License as published by the
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
7 # Free Software Foundation; either version 2, or (at your option) any
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
8 # later version.
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
9 #
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
10 # Octave is distributed in the hope that it will be useful, but WITHOUT
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
13 # for more details.
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
14 #
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
16 # along with Octave; see the file COPYING. If not, write to the Free
1315
611d403c7f3d [project @ 1995-06-25 19:56:32 by jwe]
jwe
parents: 1014
diff changeset
17 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
18
1610
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
19 function curr_axis = axis (ax)
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
20
595
a0cc17145462 [project @ 1994-08-09 18:42:23 by jwe]
jwe
parents: 594
diff changeset
21 # usage: axis ()
a0cc17145462 [project @ 1994-08-09 18:42:23 by jwe]
jwe
parents: 594
diff changeset
22 # axis ([xmin, xmax])
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
23 # axis ([xmin, xmax, ymin, ymax])
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
24 # axis ([xmin, xmax, ymin, ymax, zmin, zmax])
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
25 #
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
26 # Sets the axis limits.
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
27 #
595
a0cc17145462 [project @ 1994-08-09 18:42:23 by jwe]
jwe
parents: 594
diff changeset
28 # With no arguments, turns autoscaling on.
a0cc17145462 [project @ 1994-08-09 18:42:23 by jwe]
jwe
parents: 594
diff changeset
29 #
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
30 # If your plot is already drawn, then you need to REPLOT before
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
31 # the new axis limits will take effect.
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
32
1610
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
33 # This may not be correct if someone has used the gnuplot interface
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
34 # directly...
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
35
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
36 global __current_axis__;
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
37
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
38 if (! exist ("__current_axis__"))
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
39 __current_axis__ = [-10, 10, -10, 10];
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
40 endif
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
41
595
a0cc17145462 [project @ 1994-08-09 18:42:23 by jwe]
jwe
parents: 594
diff changeset
42 if (nargin > 1)
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 595
diff changeset
43 usage ("axis ([xmin, xmax, ymin, ymax, zmin, zmax])");
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
44 endif
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
45
595
a0cc17145462 [project @ 1994-08-09 18:42:23 by jwe]
jwe
parents: 594
diff changeset
46 if (nargin == 0)
a0cc17145462 [project @ 1994-08-09 18:42:23 by jwe]
jwe
parents: 594
diff changeset
47 set autoscale;
1610
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
48 curr_axis = __current_axis__;
595
a0cc17145462 [project @ 1994-08-09 18:42:23 by jwe]
jwe
parents: 594
diff changeset
49 elseif (is_vector (ax))
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
50
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
51 len = length (ax);
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
52
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
53 if (len != 2 && len != 4 && len != 6)
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
54 error ("axis: expecting vector with 2, 4, or 6 elements");
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
55 endif
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
56
1610
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
57 __current_axis__ = reshape (ax, 1, len);
26a096727e89 [project @ 1995-11-03 05:57:27 by jwe]
jwe
parents: 1315
diff changeset
58
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
59 if (len > 1)
594
45172f0adca5 [project @ 1994-08-09 05:38:41 by jwe]
jwe
parents: 590
diff changeset
60 eval (sprintf ("set xrange [%g:%g];", ax (1), ax (2)));
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
61 endif
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
62
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
63 if (len > 3)
594
45172f0adca5 [project @ 1994-08-09 05:38:41 by jwe]
jwe
parents: 590
diff changeset
64 eval (sprintf ("set yrange [%g:%g];", ax (3), ax (4)));
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
65 endif
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
66
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
67 if (len > 5)
594
45172f0adca5 [project @ 1994-08-09 05:38:41 by jwe]
jwe
parents: 590
diff changeset
68 eval (sprintf ("set zrange [%g:%g];", ax (5), ax (6)));
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
69 endif
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
70
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
71 else
595
a0cc17145462 [project @ 1994-08-09 18:42:23 by jwe]
jwe
parents: 594
diff changeset
72 error ("axis: expecting no args, or a vector with 2, 4, or 6 elements");
590
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
73 endif
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
74
8e42786004d6 [project @ 1994-08-09 01:18:13 by jwe]
jwe
parents:
diff changeset
75 endfunction