home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / SCRIPTS.ZIP / scripts.fat / plot / axis.m < prev    next >
Text File  |  1999-12-24  |  3KB  |  80 lines

  1. ## Copyright (C) 1996, 1997 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.
  19.  
  20. ## -*- texinfo -*-
  21. ## @deftypefn {Function File} {} axis (@var{limits})
  22. ## Sets the axis limits for plots.
  23. ## 
  24. ## The argument @var{limits} should be a 2, 4, or 6 element vector.  The
  25. ## first and second elements specify the lower and upper limits for the x
  26. ## axis.  The third and fourth specify the limits for the y axis, and the
  27. ## fifth and sixth specify the limits for the z axis.
  28. ## 
  29. ## With no arguments, @code{axis} turns autoscaling on.
  30. ## 
  31. ## If your plot is already drawn, then you need to use @code{replot} before
  32. ## the new axis limits will take effect.  You can get this to happen
  33. ## automatically by setting the built-in variable @code{automatic_replot}
  34. ## to a nonzero value.
  35. ## @end deftypefn
  36.  
  37. ## Author: jwe
  38.  
  39. function curr_axis = axis (ax)
  40.  
  41.   ## This may not be correct if someone has used the gnuplot interface
  42.   ## directly...
  43.  
  44.   global __current_axis__ = [-10, 10, -10, 10];
  45.  
  46.   if (nargin > 1)
  47.     usage ("axis ([xmin, xmax, ymin, ymax, zmin, zmax])");
  48.   endif
  49.  
  50.   if (nargin == 0)
  51.     gset autoscale;
  52.     curr_axis = __current_axis__;
  53.   elseif (is_vec (ax))
  54.  
  55.     len = length (ax);
  56.  
  57.     if (len != 2 && len != 4 && len != 6)
  58.       error ("axis: expecting vector with 2, 4, or 6 elements");
  59.     endif
  60.  
  61.     __current_axis__ = reshape (ax, 1, len);
  62.  
  63.     if (len > 1)
  64.       eval (sprintf ("gset xrange [%g:%g];", ax (1), ax (2)));
  65.     endif
  66.  
  67.     if (len > 3)
  68.       eval (sprintf ("gset yrange [%g:%g];", ax (3), ax (4)));
  69.     endif
  70.  
  71.     if (len > 5)
  72.       eval (sprintf ("gset zrange [%g:%g];", ax (5), ax (6)));
  73.     endif
  74.  
  75.   else
  76.     error ("axis: expecting no args, or a vector with 2, 4, or 6 elements");
  77.   endif
  78.  
  79. endfunction
  80.