1 ## Copyright (C) 1998, 2000, 2004, 2005, 2007
2 ## Auburn University. All rights reserved.
5 ## This program 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 3 of the License, or (at
8 ## your option) any later version.
10 ## This program 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.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} __axis_limits__ (@var{axdata})
21 ## Determine axis limits for 2-D data (column vectors); leaves a 10%
22 ## margin around the plots.
23 ## Inserts margins of +/- 0.1 if data is one-dimensional
24 ## (or a single point).
29 ## @var{n} by 2 matrix of data [@var{x}, @var{y}].
35 ## Vector of axis limits appropriate for call to @command{axis} function.
39 function axvec = __axis_limits__ (axdata)
41 if (nargin < 1 || isempty (axdata))
45 ## compute axis limits
48 delv = (maxv-minv)/2; # breadth of the plot
49 midv = (minv + maxv)/2; # midpoint of the plot
50 axmid = [midv(1), midv(1), midv(2), midv(2)];
51 axdel = [-0.1, 0.1, -0.1, 0.1]; # default plot width (if less than 2-d data)
54 axdel(1:2) = [-0.1*midv(1), 0.1*midv(1)];
57 axdel(3:4) = [-0.1*midv(2), 0.1*midv(2)];
60 ## they're at least one-dimensional
61 tolv = max(1e-8, 1e-8*abs(midv));
62 if (abs (delv(1)) >= tolv(1))
63 axdel(1:2) = 1.1*[-delv(1),delv(1)];
65 if (abs (delv(2)) >= tolv(2))
66 axdel(3:4) = 1.1*[-delv(2),delv(2)];
69 axvec = axmid + axdel;